>>>> "Craig" == Craig Lanning
<CraigL(a)internetx.net> writes:
Craig> At 09:33 AM 8/25/98 +0200, Michael Sperber [Mr. Preprocessor] wrote:
>>>>>> "Clemens" == Clemens Heitzinger
<cheitzin(a)rainbow.studorg.tuwien.ac.at> writes:
>
Clemens> What is "the right thing"?
>
> I'll say it once again: The right thing is that macros respect the
> same scoping rules as the underlying language.
Craig> Which time? Scoping rules get applied to CL macros twice, once when the
Craig> macro function is executed, and again when the result of the macro is
Craig> executed. (Let's remember, a macro is just a function that returns an
Craig> executable form as its value.)
Well, the lexical environment of the macro definition only gets
applied to the *definition* of the macro. The lexical environment of
the *use* gets applied to its expansion. This is contrary to how
lexical scoping normally works, the body of a function (corresponding
to the body, i.e. expansion of a macro) is executed in the lexical
environment of its definition, not of its use.
Craig> It seems that we are approaching the point where we "agree to
disagree".
Craig> The CL people are used to doing macros the CL way and,
Craig> consequently, don't see much benefit to the Scheme method of
Craig> doing macros. The Scheme people, on the other hand, are used
Craig> to doing macros the Scheme way and don't see much benefit to
Craig> the CL method of doing macros. We have each learned to work
Craig> around the deficiencies of our preferred Lisp environments.
I don't see the difference here. I definitely see the benefits of CL
macros, which are very powerful and expressive. There are things you
cannot do with Scheme macros because of the constraints of the pattern
language. However, there are two nits I have with it:
- It is not expressive enough to make macros obey standard CL scoping.
- It is too expressive in the sense that even with very simple macros,
you have to take special care to avoid potential name capture
problems. This is especially concerning as a name capture bug can
show up years after the macro definition has been written.
Scheme takes the stance that there are two approaches to doing macros:
a high-level approach (as standardized by R5RS), and a low-level
approach. Ideally, the high-level macro system can be implemented
with the low-level system.
Designing a decent low-level macro system is very difficult, which is
why there's no standard yet. (Even though things have boiled down to
2 or 3 alternatives by now.) CL-style macros are not powerful enough
to express Scheme high-level macros.
--
Cheers =8-} Chipsy
Friede, Völkerverständigung und überhaupt blabla