sperber(a)informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor]) writes:
> >>>>> "Craig" == Craig Lanning <CraigL(a)internetx.net> writes:
>
> Craig> At 10:01 AM 8/17/98 +0200, Michael Sperber [Mr. Preprocessor] wrote:
>
> >> This indeed shows the CONS example to be poor. The point remains the
> >> same, however: What if we bind a variable bound in a macro. Say,
> >> *features*? What if a temporary identifier in a macro definition
> >> shadows a binding in a use?
>
> Craig> I think I see what you're driving at, but I'm not sure that it's as
> Craig> important as it's being made out to be. It's easy enough to use
> Craig> MAKE-SYMBOL to create safe variable names for the macro and still
> Craig> maintain readability.
>
> Sure, but there's no guarantee that a given macro has hygienic
> behavior. Generally, maintaining hygiene this way is pretty tedious,
> which is why programmers usually don't go to the necessary lengths.
>
> Also, a macro might refer to bindings whose names are free in the
> macro definition. There's no guarantee that you'll get the same
> bindings for a use that you referred to at the point of definition.
Maintaining hygiene is *not* pretty tedious. If you want your CL macro
to be hygienic, use
(defmacro with-hygienic-variables (var &body body)
`(let ,(loop for var in vars collect
`(,var (make-symbol ,(symbol-name var))))
,@body))
This is due to a posting from Erik Naggum to comp.lang.lisp, and it
implements what Craig is talking about some paragraphes above.
Therefore, in situations where non-hygienic macros have advantages,
use a non-hygienic macro. When you want hygienic variables, use the
macro above (or write your own define-hygienic-macro, which uses the
above). It is as simple as that.
Yours,
--
Clemens Heitzinger
Student der Techn. Mathematik, Technische Universität Wien, Österreich
Vienna University of Technology, Austria