[Openmcl-devel] Compiler warnings
james.anderson at setf.de
Mon Oct 19 16:23:06 EDT 2009
On 2009-10-19, at 20:15 , Daniel Weinreb wrote:
> Whenever Common Lisp sees a symbol being used
> as a variable, which means evaluting it or binding
> it or setting it, it has to decide whether this is a
> "lexical" or "dynamic" ("special") reference.
yes, if the implementation is of common lisp.
> But traditionally it's been possible to just walk
> up to a Lisp REPL and start doing things like
> (setq z 4)
> and expect to "globally set z to 4".
but, if the implementation is of common lisp, it cannot do this.
if it does do do this, then all bets are off, as we have entered a
realm outside of the spec.
it creates a binding with indefinite scope and indefinite extent.
steele takes chapter three to set clear the concepts of scope and
extent, yet defines no variable class to cover this combination.
neither does the spec.
- it cannot be a lexical variable, as that would require a lexical
- there can be no lexical environment, as there can be no lexical
scope, because there is no establishing form.
- it cannot be a dynamic variable, as that would require a dynamic
environment. of which there is none, as the binding at issue has
indefinite extent, not dynamic extent. there is also no declaration.
- it cannot be a special variable, as that is the same as a
- it is not a global variable, as it is neither a dynamic
variable, not a constant variable.
where does that leave one, when all operators of the setf/setq family
are defined to operate on a variable of one of these defined kinds only.
as such one can only commiserate with mr dachraou, when he tries to
figure out why such a thing necessarily behaves the way it does.
not to mention, that it behaves differently in different purportedly
yes, cmucl allows that it is not really doing "the right
thing" [http://www.cons.org/cmucl/FAQ.html], but if you don't already
understand what it is doing, there is little hope for clarity.
the one clear, conformant consequence of such a set operation should
be an error - whether interpreted or compiled.
there must have been a lisp-in-the-old-days which actually did this.
was it so reviled, that everyone decided, "just go ahead and bind
it"? for convenience sake?
> That can only happen
> if z is treated as a special variable. CMUCL actually
> declares the symbol z to be special, side-effecting the global
> environment, which means any future references to
> z as a variable, even if they could have been interpreted as lexical,
> will now be interpreted as special. CCL doesn't do
> that, and I don't think other implementations do either.
> So (as I understand it) CCL in this case interprets z as
it interprets it as bound.
> but does not declare the symbol z to be special,
> so any code in the future that uses z in a normal lexical
> way will do what it would have done in the absence
> of the "setq" that happened at top level.
More information about the Openmcl-devel