samth
2020-5-25 14:45:45

@mbutterick you want -l


evyatar2013
2020-5-25 15:48:03

Hey all, In the “basic” tutorial for beautiful racket the author explains the following bit: > To generate the LINE-FUNC … names, we first put those NUM matches inside a new syntax template as #’(NUM …). Then, just as we did in the b-line macro, use http://docs.racket-lang.org/br/index.html#(def._((lib._br/syntax..rkt)._prefix-id))\|prefix-id to prefix each of them with line-. (This time, we don’t need to worry about source locations.) With this update, the finished macro looks like this: Causing two macros with hard coded prefix-ids: 1) (define-macro (b-line NUM STATEMENT ...) (with-pattern ([LINE-NUM (prefix-id "line-" #'NUM #:source #'NUM)]) 2) (define-macro (b-module-begin (b-program LINE ...)) (with-pattern ([((b-line NUM STATEMENT ...) ...) #'(LINE ...)] [(LINE-FUNC ...) (prefix-id "line-" #'(NUM ...))]) Question: What’s the “rackety” way to define this prefix in one place and refer to it as a variable. In other languages I’d create some sort of global called “PREFIX-ID”, but I assume this is bad form in racket?


samth
2020-5-25 15:49:14

no, that’s fine


soegaard2
2020-5-25 15:51:01

If you define it in the same module, remember that b-line and b-module-begin needs the value at compile time (phase 1), so you need to define as: (begin-for-syntax (define line-prefix "line-")).


evyatar2013
2020-5-25 15:52:02

Thanks to the both of you :slightly_smiling_face:


dbriemann
2020-5-25 18:20:19

@dbriemann has joined the channel


evyatar2013
2020-5-25 18:43:10

You mentioned, “if you define it in the same module”. What would be the correct mechanic if each usage of my constant is in different files?


soegaard2
2020-5-25 18:44:25

Then you need to use (require (for-syntax "the-module-with-configuration.rkt")) to import it in the file, you use line-prefix.


soegaard2
2020-5-25 18:45:15

And in "the-module-with-configuration.rkt" you’ll just have (define line-prefix "line-") and (provide line-prefix).


evyatar2013
2020-5-25 18:45:55

Thank you so much!


robert.postill
2020-5-26 05:44:12

Are there a set of exemplary packages I could look at? i’m just getting into package development and I’m looking for inspiration.


soegaard2
2020-5-26 05:46:32

@robert.postill Yes… I think there is a blog post … somewhere… with a nice example. Hopefully some of the others can remember where exactly.



robert.postill
2020-5-26 05:47:59

@soegaard2 I found https://blog.racket-lang.org/2017/10/tutorial-creating-a-package.html and that’s good but a little light on the end result


soegaard2
2020-5-26 05:49:13

There is also a section in Beatiful Racket: https://beautifulracket.com/jsonic-3/the-package-server.html


soegaard2
2020-5-26 05:49:39

But try it - and ask here if you get stuck.


robert.postill
2020-5-26 05:50:41

Sweet thanks