186 lines
11 KiB
HTML
186 lines
11 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 SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS 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/iss339_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss340.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss341_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/iss339_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss340.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss341_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss340.htm">SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS</A><P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/s_symbol.htm#symbol-macrolet"><B>SYMBOL-MACROLET</B></A>, <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> proclamation,<P>
|
|
AUGMENT-ENVIRONMENT,<P>
|
|
<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A>, VARIABLE-INFORMATION<P>
|
|
Related issues: Issue <A HREF="iss337.htm">SYMBOL-MACROLET-DECLARE</A><P>
|
|
Issue <A HREF="iss338.htm">SYMBOL-MACROLET-SEMANTICS</A><P>
|
|
Issue <A HREF="iss342.htm">SYNTACTIC-ENVIRONMENT-ACCESS</A><P>
|
|
Issue <A HREF="iss085.htm">CONSTANTP-ENVIRONMENT</A><P>
|
|
Issue <A HREF="iss084.htm">CONSTANTP-DEFINITION</A><P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit history:</B> v1, 15 Feb 1991, Sandra Loosemore<P>
|
|
v2, 13 Mar 1991, Sandra Loosemore<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
Can a symbol-macro definition shadow a variable that has been<P>
|
|
PROCLAIMed <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> or defined as a constant using DEFCONSTANT?<P>
|
|
<P>
|
|
Both <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> proclamations and <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> definitions pervasively<P>
|
|
affect the semantics of variable bindings. The question is whether a<P>
|
|
symbol-macro binding of a symbol in the variable namespace is a <P>
|
|
variable binding in this sense.<P>
|
|
<P>
|
|
Note that issues <A HREF="iss337.htm">SYMBOL-MACROLET-DECLARE</A> and <A HREF="iss342.htm">SYNTACTIC-ENVIRONMENT-ACCESS</A><P>
|
|
<A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> that an error be signalled if a <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> declaration is supplied <P>
|
|
for a name being bound as a symbol-macro.<P>
|
|
<P>
|
|
There are two proposals, SHADOWING-PERMITTED and SIGNALS-AN-ERROR.<P>
|
|
<P>
|
|
<B>Proposal (SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS:SHADOWING-PERMITTED):<P>
|
|
</B><P>
|
|
Clarify that a SYMBOL-MACRO definition of a symbol shadows any other<P>
|
|
interpretation of that symbol as a variable, even if the symbol is<P>
|
|
a keyword or has been PROCLAIMed <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> or defined as a constant <P>
|
|
using <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A>.<P>
|
|
<P>
|
|
Note that lexical shadowing of keywords and defined constants <P>
|
|
requires the use of an environment argument with <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> (see issue <P>
|
|
<A HREF="iss085.htm">CONSTANTP-ENVIRONMENT</A>). Clarify that if the first argument to<P>
|
|
<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> is a symbol that is a keyword or globally defined as a <P>
|
|
constant, <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> must return true only if that symbol is not <P>
|
|
lexically shadowed by a symbol-macro definition in the specified <P>
|
|
environment. Likewise, VARIABLE-INFORMATION returns :SYMBOL-MACRO <P>
|
|
rather than :CONSTANT as its first value if the symbol is a keyword <P>
|
|
or defined constant that has been lexically shadowed by a symbol-macro <P>
|
|
definition in the specified environment.<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
This is a reasonable interpretation to some people.<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal (SYMBOL-MACROS-AND-PROCLAIMED-SPECIALS:SIGNALS-AN-ERROR):<P>
|
|
</B><P>
|
|
Clarify that a SYMBOL-MACRO definition of a symbol that is a keyword<P>
|
|
or that has been PROCLAIMed <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> or defined as a constant using<P>
|
|
<A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A> is not permitted.<P>
|
|
<P>
|
|
Require <A REL=DEFINITION HREF="../Body/s_symbol.htm#symbol-macrolet"><B>SYMBOL-MACROLET</B></A> to signal an error if any of the symbols being <P>
|
|
bound as a symbol-macro are keywords, PROCLAIMed <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> or defined as<P>
|
|
a constant using <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A>.<P>
|
|
<P>
|
|
Require AUGMENT-ENVIRONMENT to signal an error if any of the symbols in <P>
|
|
the :SYMBOL-MACRO alist are keywords, PROCLAIMed <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> or defined as a<P>
|
|
constant using <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A>.<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
This is a reasonable interpretation to some people.<P>
|
|
<P>
|
|
There is also a compatibility problem if <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> is permitted to<P>
|
|
be sensitive to the lexical environment in which the form appears <P>
|
|
(see the cost to users section below).<P>
|
|
<P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
#1: (<A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>defvar</B></A> *foo* nil)<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_symbol.htm#symbol-macrolet"><B>symbol-macrolet</B></A> ((*foo* t))<P>
|
|
*foo*)<P>
|
|
<P>
|
|
Under proposal SHADOWING-PERMITTED, this returns T.<P>
|
|
Under proposal SIGNALS-AN-ERROR, an error is signalled.<P>
|
|
<P>
|
|
<P>
|
|
#2: (<A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>defconstant</B></A> frob "frob-constant")<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>defmacro</B></A> see-if-constant (form)<P>
|
|
`(<A REL=DEFINITION HREF="../Body/s_progn.htm#progn"><B>progn</B></A> ,form ,(<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>constantp</B></A> form)))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_symbol.htm#symbol-macrolet"><B>symbol-macrolet</B></A> ((frob (<A REL=DEFINITION HREF="../Body/f_funcal.htm#funcall"><B>funcall</B></A> #'some-hairy-function)))<P>
|
|
(see-if-constant frob))<P>
|
|
<P>
|
|
Under proposal SHADOWING-PERMITTED, this returns T; note that<P>
|
|
the call to <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> returns a value appropriate for the<P>
|
|
null lexical environment but does not take into account the<P>
|
|
local symbol-macro definition of FROB.<P>
|
|
<P>
|
|
Under proposal SIGNALS-AN-ERROR, an error is signalled.<P>
|
|
<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Apparently shadowing is permitted in some implementations but not<P>
|
|
others.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Proposal SHADOWING-PERMITTED is more work than SIGNALS-AN-ERROR<P>
|
|
since all calls to <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> within the implementation need to be <P>
|
|
examined to see whether an environment argument must be passed. This<P>
|
|
also requires that something other than <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> (like <A REL=DEFINITION HREF="../Body/f_funcal.htm#funcall"><B>FUNCALL</B></A> of ENCLOSE)<P>
|
|
be used to compute the value of something that is <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A>.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
Many applications that now use <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> assume that the value it returns<P>
|
|
is not sensitive to the lexical environment in which the form appears.<P>
|
|
(Since <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> has <A REL=DEFINITION HREF="../Body/a_not.htm#not"><B>not</B></A> previously been specified to accept an <P>
|
|
environment argument, it is hard to see how any other interpretation<P>
|
|
could be made.) Proposal SHADOWING-PERMITTED represents an incompatible <P>
|
|
change in this respect. All calls to <A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A> within user programs <P>
|
|
would have to be examined to see whether an environment argument must <P>
|
|
be passed. This also requires that something other than <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> (like <P>
|
|
<A REL=DEFINITION HREF="../Body/f_funcal.htm#funcall"><B>FUNCALL</B></A> of ENCLOSE) be used to compute the value of something that is <P>
|
|
<A REL=DEFINITION HREF="../Body/f_consta.htm#constantp"><B>CONSTANTP</B></A>.<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
The language specification is unnecessarily vague.<P>
|
|
<P>
|
|
<B>Performance impact:<P>
|
|
</B><P>
|
|
Probably none.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
The cost of non-adoption is avoided.<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
Seems to depend on who you talk to.<P>
|
|
<P>
|
|
Most people seem to acknowledge that shadowing proclaimed specials and<P>
|
|
defined constants with symbol-macros is abominable programming style.<P>
|
|
<P>
|
|
Some people think disallowing shadowing complicates the language<P>
|
|
unnecessarily by introducing yet another special case.<P>
|
|
<P>
|
|
Some people think permitting shadowing complicates the language<P>
|
|
unnecessarily by destroying the "globalness" of special proclamations <P>
|
|
and constant definitions.<P>
|
|
<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
This issue was discussed on the x3j13 mailing list in May/June 1990.<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>
|