heefoo
2021-9-4 11:52:08

can someone point me to the documentation instructions of “how to compile the cgc racket libraries” ?


heefoo
2021-9-4 11:53:15

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.”


xlambein
2021-9-4 12:48:55

Is there a way to do something like (local-require (prefix-in foo: my-module-name)) where my-module-name would be dynamically determined?


sorawee
2021-9-4 12:52:46

How would Racket determine ids to be defined (which is done statically)?


xlambein
2021-9-4 12:53:53

:smile: fair enough, I didn’t know this was done statically


sorawee
2021-9-4 12:57:03

When you build Racket, in the ./configure step, you can specify the --enable-cgcdefault option


sorawee
2021-9-4 13:06:17

heefoo
2021-9-4 13:18:19

ironicaly i did a configure ./configure —help-bc | rg cgc and didnt turn up


heefoo
2021-9-4 13:18:26

thanks


samth
2021-9-4 14:57:54

You probably want to use dynamic-require


xlambein
2021-9-4 14:58:50

Yeah but is there a way to import all the exports from a module with it?


sorawee
2021-9-4 15:04:54

I mean, can you write an example of how you expect it to work?


ben.knoble
2021-9-4 15:07:21

You might be able to get something out of module->exports and dynamic-require


xlambein
2021-9-4 15:08:33

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)


sorawee
2021-9-4 15:11:54

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?


xlambein
2021-9-4 15:14:25

Yep I see, that makes sense


ben.knoble
2021-9-4 15:15:33

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


sorawee
2021-9-4 15:22:24

This is probably considered a “bug”


samth
2021-9-5 01:36:56

You could even write a function that does that


ben.knoble
2021-9-5 01:38:48

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?)


sorawee
2021-9-5 01:40:06

I think samth meant, you can create a function that returns a dictionary mapping symbols to values.


samth
2021-9-5 01:40:22

If you want it to be a define then yes you’d need a macro


samth
2021-9-5 01:40:33

I was just thinking you could return the values


samth
2021-9-5 01:40:42

As @sorawee says