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

I have seen this problem show up from time to time, but no real answer.
(feel free to tell me to go away if you think I should.)

ANSI Common Lisp is quite elaborate on the compilation environment, but I
am not clear as to whether the compilation environment is reset upon
commencing compilation of a file, so I assume that it should not be reset
(i.e., made empty, inheriting everything from the evaluation environment).

this means that free `special' declarations in the compiler environment may
affect code compiled later adversely.  the maintenance issues in ensuring
that improper declarations are not made are non-trivial.  it would make
sense, I think, to have a `lexical' declaration that would "reverse" any
possible `special' declaration in effect at the time.

I recognize that it would not be useful to let all binding forms default to
lexical scope unless a bound `special' declaration occurs in it scope, but
given this, there are no mechanisms to avoid undesirable free `special'
declarations, _except_ for the "surround it with asterisks on both sides if
it is `special' globally" _convention_.

the reason I ask this question is also practical.  I have been burnt by
CMUCL's treating (setq foo bar) at top-level as an implicit `special'
declaration.  a warning is duly emitted, but when working within a single
CMUCL image for a day or more, such warnings may easily be forgotten.

(this can also be construed as a question whether CMUCL is conforming in
its implicitly declaring free variables special when setq'd at top-level.
I can find no requirements either way for such behavior in ANSI CL.)

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