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

Re: Issue DEFCONSTANT-NOT-WIRED (V2)



> Date: Thu, 27 Oct 88  19:15:29 CDT
> From: David N Gray <Gray@DSG.csc.ti.com>
> 
> Proposal DEFCONSTANT-NOT-WIRED:NEW-DECLARATION
> 
>   Add a new declaration to the language:
> 
>     (CONSTANT {varname}+)
>

I have two problems with this proposal:

(1) The behavior for all the cases of special and lexical variables seems
    too complicated and confusing, and I'm not even sure that it covers
    all the cases.  For example, does it make sense to have a "free"
    CONSTANT declaration?

(2) I don't think we should require SETQ'ing the variable to signal an error
    under any circumstances, since DEFCONSTANT doesn't require it.

A possible solution for the first problem is to make the CONSTANT
declaration force a lexical binding.  This is very similar to
something that Dalton and I were suggesting a couple of weeks ago to
cl-cleanup on issue PROCLAIM-LEXICAL.  To summarize, the idea was to
introduce a declaration called LEXICAL or something like that, that
does the same thing about rebinding as DEFCONSTANT does.  (Some people
seem to think that DEFCONSTANT is supposed to proclaim the variable
SPECIAL, but my reading of p. 69 of CLtL is that it is exactly the
opposite: DEFCONSTANT disallows special binding of the variable but
-does- allow it to be rebound lexically.)

I'd suggest making the CONSTANT declaration work the same way, except
also have it include DEFCONSTANT's prohibition against SETQ'ing.  It
should also parallel the SPECIAL declaration's scoping behavior.

That is, for a CONSTANT proclamation:

    References to the variable are treated as references to the
    symbol's global value.

    It is an error if there are any special bindings of the variable.
    Any further binding of that special variable is an error.

    It is an error to SETQ the symbol's global value.

    A compiler may also choose to issue warnings about bindings of the
    lexical variable of the same name.


For a "free" CONSTANT declaration:

    References to the variable are treated as lexical references.

    It is an error to SETQ the named lexical variable within the scope
    of the declaration.


For a "bound" CONSTANT declaration:

    The CONSTANT declaration forces the variable to be bound lexically.
    (The interpreter would not be able to ignore CONSTANT declarations,
    for exactly the same reasons that it cannot ignore SPECIAL
    declarations.)

    It is an error to SETQ the named lexical variable within the scope
    of the declaration.

    A compiler may also choose to issue warnings about bindings of the
    lexical or special variable of the same name, within the lexical
    scope of the declaration.

How does this sound as an alternative?

-Sandra

-------