List Info

Thread: Bug in special declaration




Bug in special declaration
user name
2006-05-12 12:38:23
I think this is a bug, or am I wrong?

ramsunct1 cmucl-2006-05 # lisp
CMU Common Lisp Snapshot 2006-05 (19C), running on sunct1
With core: /opt/local/lib/cmucl/lib/lisp.core
Dumped on: Tue, 2006-05-02 01:29:24Z on lorien
Send questions and bug reports to your local CMUCL
maintainer, 
or see <http://ww
w.cons.org/cmucl/support.html>.
Loaded subsystems:
    Python 1.1, target Intel x86
    CLOS based on Gerd's PCL 2004/04/14 03:32:47
* (let ((a 4)) (declare (special a))
       (let ((a 2))
       (cons a (locally (declare (special a)) a))))

(2 . 4)
* (setq a 3)
Warning:  Declaring A special.

3
* (let ((a 4)) (declare (special a))
       (let ((a 2))
       (cons a (locally (declare (special a)) a))))

(2 . 2)
* (quit)

Anatoly


Bug in special declaration
user name
2006-05-12 15:29:18
+ Anatoly <ramsunct1.jinr.ru>:

| I think this is a bug, or am I wrong?

I think you're wrong, but it would be nice if you had told
us what you
did expect.

| * (let ((a 4)) (declare (special a))
|        (let ((a 2))
|        (cons a (locally (declare (special a)) a))))
| 
| (2 . 4)

Correct:  The car here is the inner a, lexical.  The cdr is
the outer a (special) because of the LOCALLY declaration.

| * (setq a 3)
| Warning:  Declaring A special.

Note the warning:  CMUCL has now declared a special for you.
This behaviour is somewhat controversial, though not
illegal, so it is
customizable by using *top-level-auto-declare*.

| * (let ((a 4)) (declare (special a))
|        (let ((a 2))
|        (cons a (locally (declare (special a)) a))))
| 
| (2 . 2)

Correct:  Both bindings of a are now special because a was
globally
declared special before.  So the outer is not visible, and
only the
inner counts.

I hope this clears up the confusion.

- Harald


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )