RFC -- HYGIENIC MACROS IN PYTHON

Courageous jkraska at san.rr.com
Sat Feb 16 01:16:12 EST 2002


>hygienic macros prevent the programmer from doing variable capture, which
>if you use it indicriminately, can cause an unholy mess, though they do so
>at the cost of incresed complexity (though you are disputing this here,
>I personally find it much easier to understand (or design) a non-hygienic
>system...

You seem to use design and understand interchangeably. They are different.

In any case, a hygienic macro behaves very similarly to a function, so it's
not all that hard to undertand. The difference is that it conceptually
mutates its arguments by implicit reference, and further, depending on
the system, can handle code itself as an argument.

>It seems like non-hygienic macros fall in the philosophy of "trust the
>programmer", which is in line with dynamic typing, signature oriented
>interfaces, etc.

One thing I'm experimenting with is making hygiene explicit. Add to the
system a first class closure, and the macro simply is or isn't hygienic
depending on whether or not a clusure is defined within it.

Alternately you could do something like

defmacro clean mymacro(...)

Where "clean" means hygienic or some such.

C//




More information about the Python-list mailing list