>>>"MS" == Michael Sperber schrieb am 19 Aug 1998
09:36:44 +0200:
MS> (defvar bar 23)
MS> (defmacro foo ()
MS> 'bar)
MS> (let ((bar 42)) (foo)) => 42
Holger> (defvar bar 23)
Holger> (defun foo () bar)
Holger> (let ((bar 42)) (foo)) => 42
MS> I'm an idiot, and my Common Lisp is obviously rusty. I'm sorry.
MS> I meant (setq bar 23) instead of (defvar bar 23).
Interestingly there is a difference whether you quote bar or not:
(setq bar 23)
(defmacro foo () 'bar)
(let ((bar 42)) (foo)) => 42
(defmacro foo () bar)
(let ((bar 42)) (foo)) => 23
So, you can get the behaviour you want, you just need to know how ;-)
Detecting this difference is of course ugly:
USER(26): (defmacro foo () 'bar)
FOO
USER(28): (pprint (macroexpand '(foo)))
BAR
USER(29): (defmacro foo () bar)
FOO
USER(30): (pprint (macroexpand '(foo)))
23
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.
Which is of course possible if you use packages in CL ;-)
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.
I was under the impression that setq at the toplevel would
automagically be declared special, but obviously this is not true for
(or required by) the current ANSI standard as readable in the
HyperSpec. (CMUCL does this, IIRC, Allegro CL doesn't).
PS: What about my second question: is it possible to obtain the CL
behaviour in Scheme ?
Holger
--
---
http://www.coling.uni-freiburg.de/~schauer ---
"Are people suffering from parenthophobia-by-proxy, mistaking
`parens' for `parents'?"
-- Erik Naggum in comp.emacs.xemacs