>>>>> "Clemens" == Clemens Heitzinger <cheitzin(a)rainbow.studorg.tuwien.ac.at> writes:
Clemens> sperber(a)informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor]) writes:
>> 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.
Clemens> Maintaining hygiene is *not* pretty tedious. If you want your CL macro
Clemens> to be hygienic, use
Clemens> (defmacro with-hygienic-variables (var &body body)
Clemens> `(let ,(loop for var in vars collect
Clemens> `(,var (make-symbol ,(symbol-name var))))
Clemens> ,@body))
I'm not sure what you're trying to do. The macro, as it stands, is
buggy. I assume you mean "vars" instead of "var" in the argument list.
Even then, it's not clear what you're trying to do. It looks just
like some syntactic sugar around renaming variables.
Clemens> Therefore, in situations where non-hygienic macros have advantages,
Clemens> use a non-hygienic macro. When you want hygienic variables, use the
Clemens> macro above (or write your own define-hygienic-macro, which uses the
Clemens> above). It is as simple as that.
Unfortunately, no. If used correctly, WITH-HYGIENIC-VARIABLES, can
only prevent inadvertent capture problems. To do this, you still
have to list the variables to be renamed explicitly, and you still
need to get the unquoting right to actually make use of them. Thus,
it makes maintaining hygiene only marginally easier. You still need
all annotations you needed originally, they just become smaller.
Hygiene, however, means that variables in macros obey the same scoping
rules as the rest of the language. WITH-HYGIENIC-VARIABLES gives you
no help whatsoever referring to lexical bindings of the macro. CL
macros are not hygienic, period.
--
Cheers =8-} Chipsy
Friede, Völkerverständigung und überhaupt blabla