> On Dec 4, 2016, at 10:27 AM, Dupéron Georges <jahvascriptman...@gmail.com> 
> wrote:
> 
> I think I found a solution which allows me to inject the (#%require lng) 
> without causing conflicts with other required module: applying an extra scope 
> to the whole body makes the other (require) forms more specific, and they can 
> shadow bindings imported by (#%require lng).

A nested scope seems like the correct solution. The macro expander does 
something similar with module body's, but it creates a pair of scopes for the 
body. I'm not sure whether you would need to do the same...

http://www.cs.utah.edu/plt/scope-sets/general-macros.html#%28part._.Modules_and_.Phases%29
 
<http://www.cs.utah.edu/plt/scope-sets/general-macros.html#(part._.Modules_and_.Phases)>

I can't see any unwanted consequences of this approach, but I also don't know 
much about how scopes work with requires.

Alex Knauth

> Here is the modified "MyLang.rkt":
> 
> #lang racket
> (provide (rename-out [my-module-begin #%module-begin]))
> (define-syntax (my-module-begin stx)
>  (syntax-case stx ()
>    [(_ real-lang body)
>     (syntax-case (local-expand #'(module m real-lang body) 'top-level (list)) 
> ()
>       [(module nm lng (#%plain-module-begin . body2))
>        #`(#%plain-module-begin
>             (#%require lng)
>             . #,((make-syntax-introducer) #'body2))])]))

> My problem seems solved, but if this extra-scope trick has some unwanted 
> consequences, I would definitely want to hear about them!


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to