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

issue DEFCONSTANT-SPECIAL, version 4



Here is the amended version that was approved at the Hawaii meeting.

Forum:		Compiler
Issue:		DEFCONSTANT-SPECIAL
References:	CLtL p. 68-69, 55-56
		Issue DEFCONSTANT-NOT-WIRED
		Issue PROCLAIM-LEXICAL
		Issue SYNTACTIC-ENVIRONMENT-ACCESS
		Issue SPECIAL-VARIABLE-TEST
Category:	CLARIFICATION
Edit History:   V1, 15 Nov 1988, Sandra Loosemore
		V2, 22 Nov 1988, Sandra Loosemore
		V3, 30 Dec 1988, Sandra Loosemore
		V4, 23 Jan 1989, Sandra Loosemore (amendment)



Problem Description:

It is unclear whether DEFCONSTANT is supposed to proclaim the variable
SPECIAL.  Page 56 says that symbols defined by DEFCONSTANT "may not be
further assigned to or bound".  Page 69 says that "further assignment
to or binding of that special variable is an error" but permits
compilers to "choose to issue warnings about bindings of the lexical
variable of the same name".  Does this mean that it is legal (but
perhaps only questionable style) to lexically rebind constants?  If
so, this would seem to imply that they must not be proclaimed SPECIAL
(since CLtL provides no way to override a SPECIAL proclamation).

Some people think that DEFCONSTANT is supposed to proclaim the
variable SPECIAL because CLtL says that DEFVAR does, and that
DEFPARAMETER is like DEFVAR, and DEFCONSTANT is like DEFPARAMETER.
Also, the use of the phrase "that special variable" rather than "the
special variable of the same name" might indicate that the variable
really is supposed to be special.


Proposal DEFCONSTANT-SPECIAL:DOESNT-MATTER:

Clarify that it is an error to rebind constant symbols as either
lexical or special variables.  (In other words, a reference to a
symbol declared with DEFCONSTANT always refers to its global value.)


Rationale:

Clarifying that lexical rebinding (as well as special rebinding) of
constants "is an error" seems to be the behavior that most users
expect.  One serious problem that might arise from allowing constants
to be rebound lexically is that it would not be reliable to include
symbolic constants in macro expansions, because the user might have
rebound them to something else.


Current Practice:

Most implementations apparently proclaim the variable special anyway.


Cost to implementors:

Minor.


Cost to users:

Probably none.  Since many implementations do proclaim the variable to
be special (while at the same time forbidding special binding), there
is probably no user code that depends upon lexical rebinding of
DEFCONSTANTs.


Benefits:

An area of confusion in the language is removed.


Discussion:

This issue is primarily a documentation clarification.  It arose
during a discussion of what the DEFCONSTANT macro might expand into.
As far as users are concerned, it makes no difference whether
constants are special or lexical, as long as all rebinding is
prohibited.  The only situation where the distinction might become
important is if a function is added to the language to test whether a
variable has been proclaimed special.

The "problem description" section of the writeup on issue
PROCLAIM-LEXICAL (version 8) also appears to assume that constants
declared with DEFCONSTANT are not special.
-------