[plt-scheme] Eq bindings at different phase levels?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Feb 20 09:36:21 EST 2010

At Sat, 20 Feb 2010 15:22:14 +0100, Remco Bras wrote:
> On Sat, Feb 20, 2010 at 3:15 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > At Sat, 20 Feb 2010 15:11:25 +0100, Remco Bras wrote:
> >> Procedures to modify the table and (re-)define transformers would be
> >> provided in phase level 0.
> >
> > Thanks for the explanation, and I hate to just keeping asking "why?",
> > but the above is the key issue. Why do you want to install compile-time
> > actions in phase 0? (Why not provide the procedures to modify the table
> > at phase level 1?)
> >
> >
> 
> I'm not particularly attached to installing them in phase 0.
> My main goal is to provide user-defined transforms, so all I really
> need is a definition form of some sort that is accessible in the base
> environment.
> In short, if a "define-with-transformer" form can be provided without
> having to install the mutable table in phase level 0, that solves the
> problem just fine.

That sounds right. If your registration function is something like

 (register 'id proc)

then you could make `define-with-transformer' expand to

 (begin-for-syntax (register 'id proc))


If your transformer bindings should have the usual lexical scope, you
can avoid a hash table and exploit even more of the macro system by
having `define-with-transformer' expand to

  (define-for-syntax id (make-my-transformer proc))

Then, `with-transformer' can use `syntax-local-value' to get an
identifier's binding.



Posted on the users mailing list.