[plt-scheme] redefining primitive syntax

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jul 16 11:54:45 EDT 2003

At Wed, 16 Jul 2003 04:24:01 -0400 (EDT), Doug Orleans wrote:
> Which makes me think
> `fluid-let-syntax' is what I want, but I couldn't get that to work
> either:
> 
> > (syntax-object->datum
>    (expand
>     '(fluid-let-syntax ((let-values
>                             (syntax-rules ()
>                               ((_ (((var) expr) ...) body ...)
>                                ((lambda (var ...) body ...) expr ...)))))
>        (let ((x 3)) x))))
> (let-values (((x) (#%datum . 3))) x)

I would have recommended `fluid-let-syntax', and now I see why it
doesn't work. It's a bug. Rather than fix it, I'm more inclined to
throw out `fluid-let-syntax' eventually (because this kind of dynamic
scope seems questionable to me, and I know how to do without
`fluid-let-syntax' in places where I currently use it).

> Is there some easy way to do what I want?  I would be happy with a
> function from syntax objects to syntax objects that replaced all
> occurences of `let-values' with the appropriate `lambda' expressions;
> the only way I can think of to do this is to structurally recurse on
> the result of `expand', using a big `syntax-case' for all the
> primitive syntax forms, but this is a little tedious.

That's the only approach I can recommend. The "kerncase.ss" module of
"syntax" may help a little.

Matthew



Posted on the users mailing list.