[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Another omission: global lexicals
Oh. OK, I see what you're saying: top level forms, instead of being
considered to be in the null lexical environment as they are now, are
instead considered to be in a particular distinguished unique lexical
environment, the "global" lexical environment. All lexical environments
"inherit from" (whatever) this one. In addition, there is a macro or
special form called DEFGLOBAL that side-effects this global environment
by adding to it a new variable/value pair.
If foo is a global lexical, and your top-level defun function makes a
reference to foo that's free with respect to the defun, then it refers
to the global lexical variable foo. But if your function does a LET of
foo, it gets a new lexical variable, just as if foo had not been in the
global lexical environment at all.
This all seems semantically consistent. One could ask why it's possible
to side-effect this lexical environment when it isn't possible to
side-effect any other lexical environment. I'm not sure that's really
relevant or interesting, but I thought I'd bring it up in case someone
else does think so.
As for your questions "Is a global lexical BOUNDP? Can you MAKUNBOUND
it?", the answers are clearly "No" and "No", just as for any other
lexical variable. If you do (defglobal foo 3) and then do (boundp'foo),
the latter is asking about the symbol foo, which has nothing to do with
the lexical variable. If you (set 'foo 3), the lexical variable is
likewise unaffected. If you do a special proclaimation on the same
name, then all references and LETs and so on will refer to the symbol
(the special variable); the global lexical variable still exists, but
there is no way to get at it. (Except maybe if you make a closure over
it before you evaluate the proclaimation!)
I'll refrain from making any comments about implementation issues, until
we're sure that we have worked out the semantics so that we know what
we're talking about and we are all talking about the same thing.