[net.lang.lisp] Lexically scoped variables in co

dyb@iuvax.UUCP (07/07/86)

>Since my original posting I have discovered that despite what the
>compiler claims in its warning, free references are not compiled as
>special variables after all!  For example if I do:
>
>(defun a () (print x))
>(defun b () (let ((x 10)) (a)))
>(setq x 5)
>
>and compile all this, the compiler says that in function A, X is
>unknown and has been declared special (i.e. X will be dynamically
>scoped.  (I should mention that this is all with respect to a Symbolics
>3600 machine.)  If the compiler warning were accurate then the
>expression (b) should return 10.  However, it in fact returns 5, which
>tells me that X is being lexically scoped.  Note that if I start with
>(defvar x 5) then (b) does return 10.  My guess is that the compiler
>warning is an obsolete relic from version 5.
>
>LSB

Try (defun b () (let ((x 10)) (declare (special x)) (a))) and see what
happens.  As you currently have it, the x in b is lexically scoped and
is therefore not visible in a.