Re: Scoping Question




The CMUCL behavior is customizable using the *top-level-auto-declare*
variable.

* (setf *top-level-auto-declare* nil)

NIL
* (setf foo 3)
;

; Warning: This variable is undefined:
; FOO
;
3
* foo

3
*


*TOP-LEVEL-AUTO-DECLARE* is an external symbol in the EXTENSIONS
package.
It is a special variable; its value is :WARN.
WARN is an external symbol in the KEYWORD package.
It is a constant; its value is :WARN.
Special documentation:
This variable controls whether assignments to unknown variables at top-level
(or in any other call to EVAL of SETQ) will implicitly declare the variable
SPECIAL. These values are meaningful:
:WARN -- Print a warning, but declare the variable special (the default.)
T -- Quietly declare the variable special.
NIL -- Never declare the variable, giving warnings on each use.


So set it to "NIL" in your init.lisp.

As far as noobs are concerned, sometimes you have to take a few
lumps....setq or setf at the top level is undefined behavior. I think
many lisp noobs learn the meaning of undefined behavior by stumbling
over this issue, and it certainly brings the issue of what a special
variable is to the forefront.

--
Fred Gilham gilham@xxxxxxxxxxx
I think it's pretty obvious that the worship of that false idol known
as the State has, in the 20th Century, had some very bad effects. The
historians I'm familiar with have settled on the number of dead as 177
million, although I've seen estimates of up to 200 million.
-Bob Wallace
.



Relevant Pages

  • Re: Predicate for lexical bindings
    ... I assume you mean that you have started up an interactive Lisp ... lower level of parse, sees the word "let" which sees there already ... but there's no symbol by that name (in the current package) so ... so it puts NIL into the CDR of that same CONS cell to ...
    (comp.lang.lisp)
  • Re: from __future__ import absolute_import ?
    ... foo not in bar ... A path below the package level is generally a good means to shoot ... to represent a python "package" structure. ...
    (comp.lang.python)
  • Re: A Question about DEFPACKAGE syntax
    ... Lisp and for not-really-Common-Lisp ... that it's easier to type:foo than to type "FOO". ... "FOO" does not create superficial symbols in the keyword package ...
    (comp.lang.lisp)
  • Re: Predicate for lexical bindings
    ... lower level of parse, sees the word "let" which sees there already ... and goes into a third level of parse. ... but there's no symbol by that name (in the current package) so ... so it puts NIL into the CDR of that same CONS cell to ...
    (comp.lang.lisp)
  • Re: Request for help constructing a simple macro
    ... Isn't an unbound symbol just a `symbol object'? ... Object in Lisp means generally all Lisp data. ... #:FOO ... No package for this symbol. ...
    (comp.lang.lisp)