At 10:01 AM 8/17/98 +0200, Michael Sperber [Mr. Preprocessor] wrote:
Yo Craig,
your message is really hard to read as its formatting is totally
broken. I'll try to reconstruct:
Sorry about the formatting. Apparently, there was some lossage between
XEmacs and Eudora. (I originally composed the message in XEmacs, saved
it as a text file, and mailed it with Eudora.) It looked OK when I sent
it. :-)
>>>>> "Craig" == Craig Lanning
<CraigL(a)internetx.net> writes:
Craig> One example that shows the "symbol names function" vs "symbol
Craig> names variable" problem is
Craig> (let ((cons '()))
Craig> (push "ghengis" cons)
Craig> (push "khubla" cons)
Craig> cons)
Craig> This is a problem in Scheme because CONS is defined to be a
Craig> function for constructing lists. Within this LET it is rebound
Craig> to be a variable holding an empty list. In CL, function and
Craig> variable bindings are separate. CONS is defined as a function
Craig> by the standard, but carries no variable definition [it is
Craig> unbound], therefore, LET is free to establish a local variable
Craig> binding for CONS and PUSH will not be confused because it will
Craig> use the function binding for CONS. This form evaluates
Craig> correctly in CL and EL.
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?
I think I see what you're driving at, but I'm not sure that it's as
important as it's being made out to be. It's easy enough to use
MAKE-SYMBOL to create safe variable names for the macro and still
maintain readability. It's also easy enough to expand (via MACROEXPAND)
the macro to see what it will look like (Zmacs will let me do this with
control-shift-M and meta-shift-M).
Craig> One example that can be fixed by use of packages is [Scheme
Craig> form]:
Craig> If the application really needs a function named CONS with
Craig> different behavior [ ... ]that CL's CONS, a new package should be
Craig> defined which shadows the CONS symbol [CL form]:
You're missing the point: When you're using a macro, you don't know
which bindings it refers to. Therefore, you have no handle whatsoever
on using the right package magic in order to avoid capture problems.
In the examples, I don't *need* to use CONS, it just might happen to
be a convenient name.
Expanding the macro should tell you everything that you need to know.
What I would also want is, that, if a macro is defined within a
certain package, and I refer to bindings from the macro, that these
bindings are relative to the package of definition rather than the
package of use, obeying the standard rules of lexical scoping. Not
having this (as in CL) introduces other dangers.
I'm not sure what "bindings from the macro" you are referring to.
All symbols in the macro definition are relative to the package of
definition and not the package of use. I depend on this for my most
common use of macros.
The fundamental reason for this and many of the other troubles in CL
(and ELisp, for that matter), is the persistent confusion between
symbols and names. Try explaining this mess to a novice in Lisp, and
you'll find out just how confusing it is. Scheme doesn't have this
historical baggage.
I don't recall having had any trouble explaining it to anyone.
--
Cheers =8-} Chipsy
Friede, Völkerverständigung und überhaupt blabla
Craig Lanning
E-Mail: CraigL(a)InternetX.net