The HS page on "Declaration SPECIAL" contains the following
example:
(setf (symbol-value 'x) 6)
(defun bar (x y) ;[1] 1st occurrence of x
(let ((old-x x) ;[2] 2nd occurrence of x -- same as 1st
occurrence
(x y)) ;[3] 3rd occurrence of x
(declare (special x))
(list old-x x)))
(bar 'first 'second) => (FIRST SECOND)
I don't understand what point the example is meant to
illustrate. As far as I can see and my tests confirm,
declaring x as special does not affect the behaviour.
Spiros Bousbouras <······@gmail.com> writes:
> The HS page on "Declaration SPECIAL" contains the following
> example:
>
> (setf (symbol-value 'x) 6)
> (defun bar (x y) ;[1] 1st occurrence of x
> (let ((old-x x) ;[2] 2nd occurrence of x -- same as 1st
> occurrence
> (x y)) ;[3] 3rd occurrence of x
> (declare (special x))
> (list old-x x)))
> (bar 'first 'second) => (FIRST SECOND)
>
> I don't understand what point the example is meant to
> illustrate. As far as I can see and my tests confirm,
> declaring x as special does not affect the behaviour.
It's illustrating that the SPECIAL declaration applies only to the
variable X introduced in (X Y), not to the X in (OLD-X X). That is,
it does not work like:
(setf (symbol-value 'x) 6)
(defun bar (x y)
(let ((old-x (locally (declare (special x)) x))
(x y))
(declare (special x))
(list old-x x)))
--
Juho Snellman