[plt-scheme] macro question

From: Felix Klock's PLT scheme proxy (pltscheme at pnkfx.org)
Date: Wed Feb 25 21:38:41 EST 2004

This is puzzling me.

I'm discovered today, to my chagrin, that MzScheme is correctly 
implementing LET-SYNTAX, keeping the definitions within the 
LETREC-SYNTAX from modifying the global namespace.  I also found 
discussions from a few years ago explaining why this is the correct 
behavior, in terms of faithfulness to R5RS.

The question is, can I write a macro that will create a LET-SYNTAX-like 
form that also acts like BEGIN, in that it will export any defines at 
the top-level of the body of the LET-SYNTAX to the context that the 
LET-SYNTAX appears in (at least, it will do so if the LET-SYNTAX appear 
at the top level).

I spent some time today trying to write such a macro, using a variety 
of techniques (such as rewriting the form as a module, or playing games 
with the current-namespace parameter and eval).  But in the end, I 
haven't managed to find anything that works.

Part of the problem is that I want the LET-SYNTAX to define macros that 
expand into definitions, which means that you really can't decouple the 
syntax-bindings from the body.  I also tried calling expand on 
#'(LET-SYNTAX (...) ...) and then using that to determine what names 
were defined, and then using that information to create a new 
expression which exports those names.  But this does not seem to work 
either, perhaps because of some interaction with hygiene.

Does any one have any insight into how to write such a macro?

-Felix

----
LUKE: But how will I know why Python is better than Perl?
YODA: You will know. When your code you try to read six months from now.



Posted on the users mailing list.