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

Re: Issue DEFCONSTANT-NOT-WIRED (V2)



>	 does it make sense to have a "free"
>     CONSTANT declaration?

It could.  That was the reason for the reference to the
DECLARE-TYPE-FREE issue -- I would want it to be consistent with
whatever behavior is finally decided for TYPE declarations.

> (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.

Page 69 of CLtL uses the "is an error" terminology, which will need to
be changed.  In the new condition terminology, the phrase "an error is
signalled" seemed more appropriate than any of the alternatives, but
maybe I should have just stuck with "is an error" for now.

> 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.

The PROCLAIM-LEXICAL proposal is interesting, but appears premature for
standardization, so I don't want to tie this proposal to it.

>    (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.)

But then why does it say "binding of that special variable is an error"
instead of "binding of the special variable with the same name ..."?  
My interpretation of that paragraph is that it is inconsistent.

> 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.
...
> How does this sound as an alternative?

It appears that the effect is the same except for a case like this:

  (defvar capacity 1000)
  (defun f1 ()
    (let ((capacity 500))
      (declare (constant capacity))
      (f2)))
  (defun f2 ()
    capacity)

Function F1 would return 500 according to my proposal, or 1000 according
to your way.  The question then becomes which result is less surprising.
I think now that it would be safest to just disallow a local CONSTANT
declaration for a special variable, since this situation is potentially
confusing and not very useful.