Hygienic macros (was: do...until wisdom needed...)

Douglas Alan nessus at mit.edu
Wed Apr 18 19:57:02 EDT 2001


hannah at schlund.de (Hannah Schroeter) writes:

> Hello!

Hi!

> >The problem with non-hygienic macros is that variable names used by the
> >macro implementation can conflict with variable names that are passed
> >into the macro.  Hygienic macros solve this problem by putting the
> >variables in different namespaces.

> And you can fix this in Lisp too, using gensyms (uniquely generated
> symbols for the purpose of macro expansion), like this:

Indeed.  It's just that many people (yours truly included) find having
to resort to gensym to be ugly and tedious.

> An advantage of that is that you *can* capture names if you intend
> to, such as in Lisp's loop macro, which locally defines a
> "loop-finish"- macro to abort the loop from inside. Something that
> can't be done IIRC with Schemes "hygienic macros".

I agree that Scheme doesn't do macros right.  First of all, they're
not procedural.  I don't want a separate language for writing macros
-- I want to write them in the language itself.  Also, they provide no
escape from the hygiene.  In order to do many nice things, you need a
way of requesting that a variable be put into the normal
namespace. Hygiene should be the rule, however, rather than the
exception.

|>oug



More information about the Python-list mailing list