[Openmcl-devel] Compiler warnings
dlw at itasoftware.com
Tue Oct 20 14:55:03 EDT 2009
Ron Garret wrote:
> Yes, but it is defensible behavior in light of what the spec says,
> namely (section 188.8.131.52.1):
> "If a form is a symbol, then it is either a symbol macro or a variable."
> "If a form is a symbol that is not a symbol macro, then it is the name
> of a variable, .... There are three kinds of variables: lexical
> variables, dynamic variables, and constant variables."
> Since a "naked" symbol that is not bound and has not been DEF...ed is
> clearly not a lexical variable nor a constant variable, one could
> reasonably conclude that it must be a dynamic variable.
I agree with all of this. The only thing that (setq a 4)
at top level can possibly mean, if it's not considered
to be illegal, is to treat the symbol a as a dynamic variable.
But for it to automatically create a declaration, which will
cause future uses of that symbol to be treated as
dynamic variables even when inside a lexical scope
that defines a variable named by that symbol, is
a different thing, and isn't necessarily implied by
the spec. So I don't agree that the CMUCL behavior
is the only reasonable thing to do.
> In fact, if one does not conclude this and simply does what CCL does
> (which I agree is reasonable behavior) then one is outside the spec.
> You have a thing that acts like a variable, but does not act like any
> of the three kinds of variables that the spec defines. (Hence my
> claim earlier in this thread that a variable created this way is
> neither lexical nor dynamic).
I'm not sure I'd interpret it that way. The thing is a symbol,
and it acts like a dynamic variable when used in this way.
But the bottom line is that there's no entirely satisfactory
>> Note: Talking about Lisp "creating a variable" can be
>> confusing. Symbols are created by the reader, at
>> read time.
> But symbols are not variables.
I know. (I probably should have put a paragraph break
between those two sentences.)
>> Symbols can be used for many things.
>> Sometimes, symbols are interpreted as variables,
>> depending on the context in which they are seen.
>> There isn't quite anything that is best called "creating
>> a variable".
> No, that's not true. When you create a binding or use DEFVAR or
> DEFCONSTANT you are creating a variable.
Well, when you do a let on a symbol that isn't declared
special, then I'd say you're creating a lexical variable,
but if you do one on a symbol that is declared special,
I would not say that you're creating a variable.
OK, I guess you could say that defvar "creates
a variable" in a sense, even though it does not actually
create any Lisp object per se. That is, the symbol foo
in (defvar foo 1) wasn't created by the defvar.
I guess it's like the phrase "he was created Earl of Gurnsey." :):)
The vocabulary just isn't nice and clear and straightforward,
which it really ought to be.
> The problem is that there is no way to create a global variable
> whose name is a symbol that is not pervasively declared special
> without going beyond the behavior specific in the spec. But users want
> that behavior.
>> I hope this helps.
> Here is my attempt at cutting through this Gordian knot:
More information about the Openmcl-devel