I'm not sure why, but this works:

(unit
  (import foo^)
  (export bar^)
  (+ foo bar)))

while this fails:

(define-syntax-rule (asyn body ...)
  (unit
    (import foo^)
    (export bar^)
    body ...))

(asyn (+ foo bar))

with the error "unit: undefined export" for any imported variables.

Somehow the (unit...) form is tied to the physical source location that it's 
written in, so if a syntax transformer tries to introduce a unit syntax, when 
the new syntax is used, the unit will consider the body spliced into it to be 
outside of it, since the body has a different source location than the actual 
definition of the syntax transformer itself.

Is there any way to work around this? I don't necessarily want to rely on 
units, so I made a general syntax that would let me swap them out according to 
my specific use of them, like (with-that-stuff etc ...) instead of (unit 
(import that-stuff^) (export) etc ...). But that doesn't work, because for no 
reason I can fathom, the etc... part gets evaluated before it gets spliced in, 
even though define-syntax says it gets spliced in before evaluation.

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