Subject: Re: toplevel variables in CMUCL, get rid of the SPECIAL declaration!
From: (Rob Warnock)
Date: 13 Jan 2001 14:18:19 GMT
Newsgroups: comp.lang.lisp
Message-ID: <93po3b$nijjl$>
Barry Margolin  <> wrote:
|  <> wrote:
| >I just want:
| >- that global variables are not necessarily declared special
| Sorry, Common Lisp doesn't have global, non-special variables.  CLTL2 says
| that if a variable reference occurs outside a construct that creates a
| lexical binding, it's taken to refer to the special variable.  I can't find
| the analogous statement in the standard, but I expect it's in there
| someplace.

Well, the CLHS glossary says:

	global variable n. a dynamic variable or a constant variable.

	lexical variable n. a variable the binding for which is in the
	    lexical environment. 

	lexical environment n. that part of the environment that contains
	    bindings whose names have lexical scope.

That's a big hint, but I think this[*] nails it: Symbols as Forms
	If a form is a symbol, then it is either a symbol macro or a variable.
	If a form is a symbol that is not a symbol macro, then it is the
	name of a variable, and the value of that variable is returned.
[*]==>	There are three kinds of variables: lexical variables, dynamic
	variables, and constant variables.

So if a variable *ever* exists when it's not lexically bound, then it's
either dynamic (special) or constant. And once special, always special,
even when subsequently bound. I take that as saying that all (non-constant)
globals are special.


p.s. Are constant variables special?  Well, it doesn't matter whether
they are or not, since binding one isn't allowed. " Constant
Variables" says:

	The consequences are undefined if an attempt is made to assign a
	value to, or create a binding for a constant variable...

and "Macro DEFCONSTANT" says:

	The consequences are undefined when constant symbols are rebound as
	either lexical or dynamic variables. In other words, a reference to
	a symbol declared with defconstant always refers to its global value.

as passed) says it even more strongly:

	Clarify that it is an error to rebind constant symbols as either
	lexical or special variables.  (In other words, a reference to a
	symbol declared with DEFCONSTANT always refers to its global value.)

Rob Warnock, 31-2-510
SGI Network Engineering
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA