can someone point me to the documentation instructions of “how to compile the cgc racket libraries” ?
The only reference i can find is https://docs.racket-lang.org/inside/embedding.html where states “Be sure to build the CGC variant, since the default is 3m.”
Is there a way to do something like (local-require (prefix-in foo: my-module-name))
where my-module-name
would be dynamically determined?
How would Racket determine ids to be defined (which is done statically)?
:smile: fair enough, I didn’t know this was done statically
When you build Racket, in the ./configure
step, you can specify the --enable-cgcdefault
option
There’s a documentation at https://github.com/racket/racket/blob/master/racket/src/bc/README.txt
ironicaly i did a configure ./configure —help-bc | rg cgc and didnt turn up
thanks
You probably want to use dynamic-require
Yeah but is there a way to import all the exports from a module with it?
I mean, can you write an example of how you expect it to work?
You might be able to get something out of module->exports
and dynamic-require
Uhh, the short snippet I gave is essentially the whole thing. Here’s a longer version, assuming the module in “my-module.rkt” exports a function bar
(define mod-name "./my-module.rkt")
(local-require (prefix-in foo: mod-name))
(foo:bar)
Racket needs to be able to tell what id is bound or unbound statically. So what you want is impossible. Imagine if my-module.rkt
exports a
, then foo:a
would be bound, but foo:bar
would not. How would Racket be able to tell that?
Yep I see, that makes sense
But, couldn’t you write a (fairly procedural) macro that looks at module->exports and define-values’s them using dynamic-require? You would control the ids defined by generating syntax for them
This is probably considered a “bug”
You could even write a function that does that
facepalm duh, of course, not sure why I didnt realize that. (Unless it was because of the define? Wouldn’t that have to be a macro to be a top-level thing? Or can a function create top-level bindings?)
I think samth meant, you can create a function that returns a dictionary mapping symbols to values.
If you want it to be a define then yes you’d need a macro
I was just thinking you could return the values
As @sorawee says