[plt-scheme] Rebinding expanded primitive syntax

From: Lauri Alanko (la at iki.fi)
Date: Sat Nov 6 15:50:32 EST 2004

Back when fluid-let-syntax was available, one could do tricks like
this:

> (fluid-let-syntax ((lambda (lambda (stx) #''foo))) (define (bar) 'baz) bar)
foo

This rebinds the lambda identifier that define _expands to_.

Although I can understand that this kind dynamic scoping breaks
abstraction barriers and the removal of fluid-let-syntax was justified,
it is still useful at times, especially when one wants to do low-level
transformations to all code, e.g. for debugging purposes. Then it's not
enough just to redefine all explicit lambdas (or #%apps etc.) in the
code that uses the module, but also those that standard (and
third-party) macros expand to. How is this to be done now that
fluid-let-syntax is to be no longer available?

I am guessing that the right way to do this would be to expand
expressions into primitive syntax and then somehow rebind the
identifiers in there with let-syntax. So far I haven't succeeded in
this, though.

I would appreciate an example of how this sort of thing is to be done in
v300.


Lauri


Posted on the users mailing list.