If you dynamically add bindings during _expansion_ (instead of expanding to 
code that _defines_ and exports something), then naturally the compiler never 
sees it, so it doesn’t end up in .go and when the .go is loaded, that binding 
isn’t there anymore.

Proposed alternative:

• Define a mapping of module->collected-strings somewhere.
• Let G_ add things to this mapping, during _expansion_ (syntax-case instead of 
syntax-rules will be needed).
• Define another macro ‘define-marked-strings’ that, during expansion, looks 
into this mapping, and from its contents constructs code that defines the 
variable.

For hygiene, to avoid state and to make it independent of the module system, 
you could try to make it in the form:

(collect-G-literals marked-strings
  [various definitions])
-> (begin [various definitions] (defined marked-strings '("bla" ...)))

There is something similar to ‘parameterize’ but for macros and syntax that may 
be useful for this, but I’m not sure if it has the required semantics.

Another option is to forego a macro implementation and instead implement it as 
a compilation pass. There doesn’t seem to be good support for plugging in 
custom extra compilation passes, though.

Best regards,
Maxime Devos

Reply via email to