On Thu, Dec 29, 2005 at 02:13:48PM -0800, Stephen Horner wrote:
> * (setf a 100)
> Warning:  Declaring A special.
  ^ warnings are relevant.

> 
> 100
> * (defun g (b) (list a b))
> 
> G
> * (defun f (a) (list a (g (+ a 1))))
> 
> F
> * (f 3)
> 
> (3 (3 4))
> *
> --------------------------------------------------------------------------------
> 
> NOTE:
> (3 (100 4)) is what what I was "taught" _should_ return. That is according to
> David S. Touretzky's Common Lisp: A gentle Introduction to Symbolic 
> Computation.
> Also (3 (100 4)) is returned in clisp-2.34-r1, and sbcl-0.9.7

Touretzsky is a bit out of date if he is recommending the usage of 
  (setf a 100) 
on an undeclared variable.  That behavior is undefined.  In CMUCL it
automatically declares A a Special variable and outputs a warning.

Seeing that his book was written prior to the standard being submitted,
I believe, it's excusable I suppose.

If you haven't reached an understanding of Special variables yet, you
may wish to consult "Common Lisp the Language ed 2" chapter on "Scope".

The behavior above is correct for a Special variable.

-- 
;; Matthew Danish -- user: mrd domain: cmu.edu
;; OpenPGP public key: C24B6010 on keyring.debian.org


Reply via email to