pika-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pika-dev] Problem with Pika's macro expander?


From: Matthew Dempsky
Subject: [Pika-dev] Problem with Pika's macro expander?
Date: 19 Feb 2004 10:36:37 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

I've been working on Pika's macro expander (as specified in Tom's
notes) over the past few days, and I think there may be an issue in
how it handles hygiene in macros similar to the R5RS definition of
LETREC (I say similar to because LETREC itself is a primitive in Pika,
but it should be considered reasonable for people to want to write
macros using the same hygiene trick or implement LETREC themselves).

LETREC first generates a list of temporary identifiers it can use by
taking advantage of the fact that the TEMP symbol needs to be hygienic
across different calls to the macro.  According to Tom's notes,
because TEMP is a symbol in the template part of the syntax-rules
clause, it gets replaced with he binding of TEMP in the expander's
environment.

However, the hygiene renaming step is not until later when we hit the
built-in expander LET (or LAMBDA) and it finds binding objects
(objects that pass the BINDING? test) in the binding position of a
form (elements of the formal parameter list of LAMBDA).  To quickly
simplify the steps Tom laid out in notes/spec/expansion, any binding
objects found are then replaced with newly generated symbols and in
the scope of the binding expression (body of LAMBDA, LET, etc.) all
the bindings are replaced with either tho old or new symbol (depending
on context).

But realize, at this point we have a list of bindings of TEMP in the
expander's environment -- in the reference implementation I'm working
on, BINDING-OF returns the actual binding (thus equivalent to the
level of EQ? while Tom only specifies to the level of EQV?), so once
whatever form is responsible for doing the renaming is reached (in my
case LAMBDA), it has a list of EQ? bindings for the formals so there's
no way for it to correctly replace the bindings with symbols in the
rest of the form.

Maybe if I added some sort of BINDING-REFERENCE type that BINDING-OF
actually returns (by creating a new one refering to the actualy
BINDING), and then these would be non-EQ? and differentiable and the
exposed function EQV? would check if the references refer to EQ?
bindings... this just seems like an `icky' solution.

Also, to correctly implement LET-SYNTAX and to generate alpha-ids, at
the very least we need to maintain a list of how repeated identifiers
are in the lexical environment so we can rename symbols to alpha-ids
(and probably need to just construct and maintain an entire
environment at expand-time, but I'll raise those issues later -- class
is almost over. :-)

-jivera




reply via email to

[Prev in Thread] Current Thread [Next in Thread]