From: sperber(a)informatik.uni-tuebingen.de (Michael Sperber [Mr. Preprocessor])
Date: 24 Aug 1998 11:14:43 +0200
No. I think the problem is that many C and Common Lisp programmers
confuse the concepts of "binding" and "assignment."
In my experience this is far more common among C programmers than CL
programmers.
. . . and in Common Lisp, assignment (via setq) may create the
binding if it doesn't exist yet.
Thus, in your example,
(setq bar 23)
Of course, many consider this sloppy. CMUCL issues a warning at this
point.
What I want is:
(setq 23)
(defmacro foo () 'bar)
(foo) => 23
(let ((bar 42)) (foo)) => 23 [note: CL actually yields 42]
(setq bar 57)
(foo) => 57
(let ((bar 42)) (foo)) => 57 [note: CL actually yields 42]
For what it's worth, CMUCL gives the values that you want, assuming
that you meant (setq bar 23) as the first form rather than (setq 23).
Rick
CMU Common Lisp 18a x86-linux 1.4.0 cvs, running on germs
Send bug reports and questions to cmucl-bugs(a)cs.cmu.edu.
Loaded subsystems:
Python 1.0, target Intel x86
CLOS based on PCL version: September 16 92 PCL (f)
*
* (setq bar 23)
Warning: Declaring Bar special.
23
* (defmacro foo () bar)
Foo
* (foo)
23
* (let ((bar 42)) (foo))
23
* (setq bar 57)
57
* (foo)
57
* (let ((bar 42)) (foo))
57
* (quit)
done.
Mapping 5021696 bytes at 0x1000000.
Mapping 7991296 bytes at 0x5000000.