Subject: Re: (declare (lexical ...))
From: Erik Naggum <>
Date: 1996/04/15
Newsgroups: comp.lang.lisp
Message-ID: <>

[Thomas A. Russ]

|   One has to consider what the alternatives are.  The expression 
|     (setq foo bar) 
|   at top-level does not have any lexical scoping forms.  I can think of
|   three possible ways to deal with this:
|     (1)  Implicitly wrap a lexical scope around the form.
|     (2)  Signal an error for an undeclared variable.
|     (3)  Implicitly make "foo" special (and warn).

I think I see a deep mistake I have made here, but it's somewhat slippery.
there are bound and free variables.  free variables are assumed to be found
in an enclosing environment; if not, they cause errors.  free variables at
top-level are not found in any environment, and is therefore in an error
situation, anyway, so anything goes?

|   This is what every lisp I have ever encountered does.

that's odd.  I'm using CMUCL 17f, CLISP 1996-03-15, WCL 2.2, and XLISP
2.1g.  among them, only CMUCL implicitly declares top-level setq'd
variables special.  incidentally, (set 'foobar 42) in CMUCL does not
declare `foobar' special, while (setq foobar 42) does.  clearly, this is a

is there anything in ANSI CL that could be construed as a requirement or at
least a helpful hint as to how this situation should be handled?

(I'm still interested in how one would "undo" a top-level (pervasive?)
special declaration.)

education is for people who can't handle reality the hard way