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

Re: Issue: PROCLAIM-LEXICAL (Version 7)



> his might be something we shouldn't even think about standardizing
> until some implementor/vendor takes the plunge in a trial balloon,

> Yes, I remember, I was mildly in favor of the original proposal; but that 
> was a year and a half ago, and I expected a GLOBAL declaration to mean that
> it would be illegal to special-bind that name (hence you could depend on
> that name *not* being in the D environment).  Had somebody implemented
> something like it for their Lisp back then, we might have had results to 
> talk about now.

I think the semantic implications of adding a declaration that prevents
dynamic binding are sufficiently straightforward that we should not
rule it out just because no one implemented it a year ago.

The strangeness in the current proposal is because the dynamic and
lexical environments meet in a separate global environment.  So
a shallow bound implementation can't just change the global cell
when it pushes a new binding.  The shallow binding cell has to
be a separate cell, making symbols (effectively) larger.  KMP
and JAR suggested the use of a single cell combined with search
for the global value if both it and the dynamic are needed.
This is a new machanism, so we might want to think twice about
it.

An alternative is to say that a given global variable can be either
lexical or special but not (as they can be in the current proposal)
both.  That's not all that strange, because it's what we get with
LET.  It lets us use a single cell and simply rules out the case
when both are needed.

I believe this alternative (which is more or less what was proposed
before minus all the stuff about CONSTANT proclamations, etc.) solves
the main problems (an easily referenced global for deep bound 
implementations and a way to establish a global variable without
proclaiming it special and without some implementations thinking
it's a spelling error or an omitted proclamation) and is fairly
noncontroversial.

We can fight about whether the proclamation for this should be called
GLOBAL or LEXICAL.  I think it is better to think of the new kind of
global variable as a kind of lexical variable rather than as a
special1 variable that can't be bound, but that may be a matter of
taste.

We might also fight, I suppose, about whether there should be a
corresponding declaration (to override special proclamations).
[It occurs to me that people might think of two different
declarations.

1.  (set-global x 10)
    (let ((x 20))
      (locally (declare (lexical x)) x)) => 20

2.  (set-global x 10)
    (let ((x 20))
      (locally (declare (global x)) x)) => 10

The one I have in mind is the 1st.]

In any case, I think there is a fallback better than "do nothing".