>>>> "Holger" == Holger Schauer
<schauer(a)coling.uni-freiburg.de> writes:
>>>> "MS" == Michael Sperber schrieb am 19 Aug
1998 09:36:44 +0200:
Holger> Interestingly there is a difference whether you quote bar or not:
Holger> (setq bar 23)
Holger> (defmacro foo () 'bar)
Holger> (let ((bar 42)) (foo)) => 42
Holger> (defmacro foo () bar)
Holger> (let ((bar 42)) (foo)) => 23
Holger> So, you can get the behaviour you want, you just need to know
Holger> how ;-)
No, this is different. When you don't quote bar, you get the value of
the binding at macro *definition time*. I want the value of the binding
at macro *use time*.
If you do a (setq bar 47) between definition and use, you'll see the
difference.
MS> I don't understand that last sentence. If I create a package,
MS> and I put abstractions in that package, may they be syntactic or
MS> semantic abstractions, I want those abstractions to be able to
MS> access bindings in the package.
Holger> Which is of course possible if you use packages in CL ;-)
Yeah, if I use explicit qualification, which amounts to not using the
package system at all.
MS> Absolutely. I just fucked up the example. In the case of
MS> special variables, you do want the macro to refer to the
MS> dynamically bound version.
Holger> I was under the impression that setq at the toplevel would
Holger> automagically be declared special, but obviously this is not true for
Holger> (or required by) the current ANSI standard as readable in the
Holger> HyperSpec. (CMUCL does this, IIRC, Allegro CL doesn't).
So what's the politically correct way to define top-level bindings
which are not special in Common Lisp?
Holger> PS: What about my second question: is it possible to obtain the CL
Holger> behaviour in Scheme ?
I'm not sure what exactly you mean. If you mean: "Can I access
bindings not within the scope of a macro from the macro?" ... then the
answer is no, just as you can't access bindings not within the scope
of an abstraction from within the abstraction. You shouldn't be able
to. If you want something equivalent to dynamic binding, you generall
use lexical scoping plus dynamic assignment in Scheme, in which case
the macro will do what you want.
--
Cheers =8-} Chipsy
Friede, Völkerverständigung und überhaupt blabla