Variable capture within hygienic and legacy macro
R7RS Scheme scripting engine
Status: Beta
Brought to you by:
shirok
String interpolation doesn't work with
hyginic macro, in the sense that
the embedded expression can't "see"
the bindings introduced by the hygienic
macro.
<pre>
(define-syntax foo
(syntax-rules
((_)
(let ((x (hoge)))
#`",x"))))
</pre>
In the above example, interpolated "x"
doesn't refer to the "x" in the syntax-rules.
Logged In: YES
user_id=126450
I found it is more general problem. Generally, when a
legacy macro is used within hygienic macro, the internal
legacy macro can't bind a variable in the original body
since it is effectively renamed.
(define-syntax foo
(syntax-rules ()
((_) (bar x))))
(define-macro (bar var)
(let ((x 2)) var))
Then, (foo) expands to
(let ((x 2)) x_RENAMED)
This is hygienic. The problem is that we need explicit
contamination here.