On Sat, 2009-09-05 at 15:41 -0400, John Cowan wrote:

> What makes macro hygiene critical, I think, is that it can't be emulated
> without being able to do a global transformation of all code, not merely
> macro definitions and calls. 

That's not quite true.

As I recall, the way we added hygienic macros to
Guile was:

1) Started with something a bit like classic old 
defmacro, but that memoizes its results.  That is,
upon first execution, unexpanded macro calls are
replaced with their expansion by doing local, not
global code rewriting.  This bit was inherited from
SCM.

2) Adding first class environments and locatives.
An F.C.E. is a mapping from names to locatives.  A
locative is the anonymous binding site of a variable.

3) Writing the hygienic system on top of that is
tedious - easy to make mistakes and took a few iterations
before it was more or less correct - but its conceptually
straightforward.  (Someone with more experience in the
matter than I had when I wrote it could well have made
fewer mistakes in the early iterations.)

A module system can also be built similarly.

So, if your lisp lacks hygienic macros but as first
class environments and defmacro - you can likely
do hygienic in a library.

Would one approach be better than the other?
I would only say that first class environments are
a natural fit for most interpretation strategies,
that they can be given a nice clean semantics, 
and that they are a more general purpose tool
than hygienic macros.

-t



_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to