[plt-scheme] Evaling syntax with module bindings

From: Lauri Alanko (la at iki.fi)
Date: Thu Feb 2 04:55:32 EST 2006

On Mon, Jan 30, 2006 at 01:58:01PM -0700, Matthew Flatt wrote:
> `eval-for-syntax' and `eval-for-template'? They make sense in
> principle, but I doubt that they're the right solution to this problem.

I've thought about this a bit, and it still seems that eval-for-template
is exactly the right solution. When I'm effectively doing manual syntax
expansion in the run-time phase, then obviously the identifiers in the
resulting code should be bound to the _next_ phase.

It's even clearer with compile. Currently, when compile is given a
syntax object as an argument, it uses the run-time bindings. But why
should my program need to require a module at run-time if I only want to
compile and save a piece of code, to be executed later, that refers to
that module? This doesn't seem very intuitive. A compile-for-template
feels like the Right Thing.

Of course this is only relevant when compiling top-level expressions,
since modules explicitly declare their bindings anyway. But it would be
nice to just create a piece of code from arbitrary bindings and not have
to worry about collating all the required modules somewhere. Like during
syntax transformation.

Effectively the problem is that a syntax transformer can only run either
before the run-time (as an ordinary macro that produces the original
program), or after the run-time (during the syntax transformation phase
of something to be compiled or evaled), but not _during_ the run-time,
in "ordinary" code. 


Lauri


Posted on the users mailing list.