[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

free variable references in interpreter.

GJC has somewhat misstated what happens both in NIL and in the MIT
(lmi) lisp machine interpreters.

The initial decision about whether a free variable reference should be
considered "an error" is made by looking at the environment in which
the form was evaluated, not at a magic variable.

"Top-level" evaluation (the sort of thing the user types at a lisp
listener) passes EVAL an environment object which says `just silently
take any free variable references to be a reference to the special
value of that variable' (which is exactly the same as the mechanism
of function lookup, incidentally)

On the other kettle of fish, "normal" evaluation, made in the null
lexical environment, (EVAL's default) signals an error when a free
variable reference occurs.  (The variable GJC mentioned,
si::*mumble-free-mumble-reference-mumble-special, is used to override
this for the use truly crufty old code which nobody wants to invest
any time in improving.  Anybody else seen binding it should be shot
with a gun)

The result of this is that a user may type "(setq foo *)" and
"(funcall (frob foo) 1)" at a lisp listener without being harrassed
too unduly, but that compiler-style detection of wild references
happens for "(eval '(setq foo *))" and so forth.

[The older way in which NIL's evaluator dealt with this situation,
 (explicitly doing a (PROCLAIM '(SPECIAL ...)) and printing a warning
 to *ERROR-OUTPUT* whenever the interpreter saw a free reference) was
 flushed some time ago in favour of the above scheme]
[Another hack is that that the environment object in the lisp machine
 implementation can also flag that -all- variable references are
 special.  This was intended to be used when people were converting
 code which ran with the old dynamic interpreter.  As it happened, not
 much  seemed to require this sort of degenerate backwardness]