115 lines
6.1 KiB
HTML
115 lines
6.1 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 SPECIAL-TYPE-SHADOWING 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/iss321_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss322.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss323_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/iss321_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss322.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss323_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue SPECIAL-TYPE-SHADOWING Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss322.htm">SPECIAL-TYPE-SHADOWING</A><P>
|
|
<P>
|
|
<B>References:</B> CLtL pages 156, 158<P>
|
|
<P>
|
|
Related issues: <A HREF="iss096.htm">DECLARE-TYPE-FREE</A><P>
|
|
<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<P>
|
|
<B>Edit history:</B> Version 1, 04-Nov-88 by David Gray<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
A Common Lisp user raised the question of whether something like the<P>
|
|
following is legal:<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_procla.htm#proclaim"><B>PROCLAIM</B></A> '(<A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> <A REL=DEFINITION HREF="../Body/t_number.htm#number"><B>NUMBER</B></A> *X*))<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> *X*)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> FOO ()<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> ((*X* T))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_declar.htm#declare"><B>DECLARE</B></A> (<A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> *X*))<P>
|
|
(BAR)))<P>
|
|
<P>
|
|
Page 156 of CLtL says that a proclamation is "always in force unless<P>
|
|
locally shadowed" and page 158 says type declarations "only affect<P>
|
|
variable bindings", which might be interpreted to mean that the <A REL=DEFINITION HREF="../Body/s_declar.htm#declare"><B>DECLARE</B></A><P>
|
|
locally shadows the <A REL=DEFINITION HREF="../Body/f_procla.htm#proclaim"><B>PROCLAIM</B></A>. However, that interpretation would make<P>
|
|
the global type proclamation useless because it could not be relied on<P>
|
|
when compiling a function such as BAR. <P>
|
|
<P>
|
|
Proposal <A HREF="iss322.htm">SPECIAL-TYPE-SHADOWING:CLARIFY</A><P>
|
|
<P>
|
|
Clarify that if there is a local type declaration for a special<P>
|
|
variable, and there is also a global type proclamation for that same<P>
|
|
variable, then the value of the variable within the scope of the local<P>
|
|
declaration must be a member of the intersection of the two declared<P>
|
|
types.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
Some restriction on local type declarations for special variables is<P>
|
|
needed in order for type proclamations to be meaningful. The wording<P>
|
|
used here was chosen for consistency with proposal <A HREF="iss096.htm">DECLARE-TYPE-FREE</A>.<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
The TI, Symbolics, and Lucid implementations do not report any error<P>
|
|
on the example above, but it isn't clear that they really do anything<P>
|
|
with type declarations for special variables anyway.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
This is unlikely to <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> a change in any current implementation.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
Anyone who has written code like the example above would have to<P>
|
|
modify it if compilers started enforcing this restriction.<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
A minor ambiguity in the language specification that could confuse<P>
|
|
users.<P>
|
|
<P>
|
|
<B>Performance impact:<P>
|
|
</B><P>
|
|
None.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
A clearer definition of the meaning of type declarations for special<P>
|
|
variables.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
This is obviously very closely related to issue <A HREF="iss096.htm">DECLARE-TYPE-FREE</A>, but<P>
|
|
this is an ambiguity in the existing language that should be resolved<P>
|
|
even if the language extension of proposal <A HREF="iss096.htm">DECLARE-TYPE-FREE</A> is not<P>
|
|
accepted. Note also that <A HREF="iss096.htm">DECLARE-TYPE-FREE</A> makes no mention of type<P>
|
|
proclamations.<P>
|
|
<P>
|
|
Other possible resolutions of the ambiguity would be to either rule<P>
|
|
out use of local type declarations for special variables, or to say<P>
|
|
that the local type must be a subtype of the global type.<P>
|
|
<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>
|