hey all, a stack overflow question has me intruiged. is it possible to reference a defined variable inside of a provide
block?
i’m looking to do (provide
(filtered-out
(λ (name) (findf (λ (n) (equal? name n)) my-funs))
(all-defined-out)))
but i get the error my-funs: unbound identifier
Does it help to place the definition of my-funs
before the provide ?
lemme just put the whole snippet in here
This is useful because I’d be using my-funs
elsewhere in the code and I don’t want to have to keep a list of provide
calls up to date when I change my-funs
The my-funs
variable needs to be available at compile time. So wrap a begin-for-syntax
around it.
#lang racket
(require racket/provide)
(define (f1 a) (+ a 1))
(define (f2 a) (+ a 2))
(begin-for-syntax
(define my-funs '(f1 f2)))
(provide (filtered-out
(λ (name)
(and (member (string->symbol name) my-funs)
name))
(all-defined-out)))
code used in filtered-out
is run at expansion time, so if you do (define-for-syntax my-funs ...)
it will work
or what @soegaard2 said
Oh - and findf
is fine to use - I had just forgotten what it did.
Awesome thank you
Hi all. Is it possible to package up a DSL so that it can be invoked as a stand-alone utility, without having to explicitly install Racket?
Do you mean create a stand-alone executable that can be called as a command line tool? E.g. mylang -run “test1.mylang”
?
Yeah
Yes, you can create an executable with raco exe and raco distribute.