119 lines
6.7 KiB
HTML
119 lines
6.7 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Issue DEFCONSTANT-SPECIAL Writeup</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="../Issues/iss098_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss099.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss100_w.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss098_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss099.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss100_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue DEFCONSTANT-SPECIAL Writeup</H2>
|
|
|
|
<PRE><B>Forum:</B> Compiler<P>
|
|
<B>Issue:</B> <A HREF="iss099.htm">DEFCONSTANT-SPECIAL</A><P>
|
|
<B>References:</B> CLtL p. 68-69, 55-56<P>
|
|
Issue DEFCONSTANT-NOT-WIRED<P>
|
|
Issue PROCLAIM-LEXICAL<P>
|
|
Issue <A HREF="iss342.htm">SYNTACTIC-ENVIRONMENT-ACCESS</A><P>
|
|
Issue SPECIAL-VARIABLE-TEST<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit History:</B> V1, 15 Nov 1988, Sandra Loosemore<P>
|
|
V2, 22 Nov 1988, Sandra Loosemore<P>
|
|
V3, 30 Dec 1988, Sandra Loosemore<P>
|
|
V4, 23 Jan 1989, Sandra Loosemore (amendment)<P>
|
|
<B>Status:</B> Proposal DOESNT-MATTER passed Jan 1989<P>
|
|
<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
It is unclear whether <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> is supposed to proclaim the variable<P>
|
|
<A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A>. Page 56 says that symbols defined by <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> "may not be<P>
|
|
further assigned to or bound". Page 69 says that "further assignment<P>
|
|
to or binding of that special variable is an error" but permits<P>
|
|
compilers to "choose to issue warnings about bindings of the lexical<P>
|
|
variable of the same name". Does this mean that it is legal (but<P>
|
|
perhaps only questionable style) to lexically rebind constants? If<P>
|
|
so, this would seem to imply that they must not be proclaimed <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A><P>
|
|
(since CLtL provides no way to override a <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> proclamation).<P>
|
|
<P>
|
|
Some people think that <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> is supposed to proclaim the<P>
|
|
variable <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> because CLtL says that <A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> does, and that<P>
|
|
<A REL=DEFINITION HREF="../Body/m_defpar.htm#defparameter"><B>DEFPARAMETER</B></A> is like <A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A>, and <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> is like <A REL=DEFINITION HREF="../Body/m_defpar.htm#defparameter"><B>DEFPARAMETER</B></A>.<P>
|
|
Also, the use of the phrase "that special variable" rather than "the<P>
|
|
special variable of the same name" might indicate that the variable<P>
|
|
really is supposed to be special.<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal DEFCONSTANT-SPECIAL:DOESNT-MATTER:<P>
|
|
</B><P>
|
|
Clarify that it is an error to rebind constant symbols as either<P>
|
|
lexical or special variables. (In other words, a reference to a<P>
|
|
symbol declared with <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> always refers to its global value.)<P>
|
|
<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
Clarifying that lexical rebinding (as well as special rebinding) of<P>
|
|
constants "is an error" seems to be the behavior that most users<P>
|
|
expect. One serious problem that might arise from allowing constants<P>
|
|
to be rebound lexically is that it would not be reliable to include<P>
|
|
symbolic constants in macro expansions, because the user might have<P>
|
|
rebound them to something else.<P>
|
|
<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Most implementations apparently proclaim the variable special anyway.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to implementors:<P>
|
|
</B><P>
|
|
Minor.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to users:<P>
|
|
</B><P>
|
|
Probably none. Since many implementations do proclaim the variable to<P>
|
|
be special (while at the same time forbidding special binding), there<P>
|
|
is probably no user code that depends upon lexical rebinding of<P>
|
|
DEFCONSTANTs.<P>
|
|
<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
An area of confusion in the language is removed.<P>
|
|
<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
This issue is primarily a documentation clarification. It arose<P>
|
|
during a discussion of what the <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> macro might expand into.<P>
|
|
As far as users are concerned, it makes no difference whether<P>
|
|
constants are special or lexical, as long as all rebinding is<P>
|
|
prohibited. The only situation where the distinction might become<P>
|
|
important is if a function is added to the language to test whether a<P>
|
|
variable has been proclaimed special.<P>
|
|
<P>
|
|
The "problem description" section of the writeup on issue<P>
|
|
PROCLAIM-LEXICAL (version 8) also appears to assume that constants<P>
|
|
declared with <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> are not special.<P>
|
|
</PRE>
|
|
<HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|