1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss313_w.htm
2024-04-01 10:24:07 +02:00

151 lines
9.9 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 SHADOW-ALREADY-PRESENT 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/iss312_w.htm">
<LINK REL=UP HREF="../Issues/iss313_m.htm">
<LINK REL=NEXT HREF="../Issues/iss315_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/iss312_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss313_m.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss315_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue SHADOW-ALREADY-PRESENT Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss313_m.htm">SHADOW-ALREADY-PRESENT</A><P>
<P>
<B>References:</B> CLtL p.186<P>
<P>
<B>Category:</B> CLARIFICATION/CHANGE<P>
<P>
<B>Edit history:</B> Version 1 Moon 24 Aug 87 <P>
Version 2 Moon 27 Aug 87 incorporate JonL's suggestions <P>
Version 3 Masinter 26-Oct-87<P>
Version 4 Masinter 10-Nov-87<P>
<P>
<B>Problem description:<P>
</B><P>
The description of the <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> function can be interpreted as saying that the<P>
function has no effect, if the symbol is already present in the package. This<P>
happens if the third sentence in the description (&quot;then nothing is done&quot;) is<P>
interpreted as applying to the entire description rather than just to the fourth<P>
sentence.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> is said to take symbols as arguments, however only the print-name is<P>
meaningful for this operation (that fact is already documented).<P>
<P>
<B>Proposal SHADOW-ALREADY-PRESENT:WORKS:<P>
</B><P>
1) The <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> function always adds the symbol to the <A REL=DEFINITION HREF="../Body/f_pkg_sh.htm#package-shadowing-symbols"><B>PACKAGE-SHADOWING-SYMBOLS</B></A><P>
list, even when the symbol is already present in the package. <P>
<P>
2) The first argument to <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> is allowed to be or contain strings as well as<P>
symbols. The specification &quot;the print name of each symbol is extracted&quot; is to be<P>
modified accordingly.<P>
<P>
<B>Test Case:<P>
</B><P>
;;; <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> always adds the symbol to the <A REL=DEFINITION HREF="../Body/f_pkg_sh.htm#package-shadowing-symbols"><B>PACKAGE-SHADOWING-SYMBOLS</B></A><P>
;;; list of a package<P>
<P>
(<A REL=DEFINITION HREF="../Body/f_mk_pkg.htm#make-package"><B>make-package</B></A> 'test-1)<P>
(<A REL=DEFINITION HREF="../Body/f_intern.htm#intern"><B>intern</B></A> &quot;TEST&quot; (<A REL=DEFINITION HREF="../Body/f_find_p.htm#find-package"><B>find-package</B></A> 'test-1))<P>
(<A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>shadow</B></A> 'test-1::test (<A REL=DEFINITION HREF="../Body/f_find_p.htm#find-package"><B>find-package</B></A> 'test-1))<P>
(<A REL=DEFINITION HREF="../Body/m_assert.htm#assert"><B>assert</B></A> (<A REL=DEFINITION HREF="../Body/a_not.htm#not"><B>not</B></A> (<A REL=DEFINITION HREF="../Body/a_null.htm#null"><B>null</B></A> (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>member</B></A> 'test-1::test (<A REL=DEFINITION HREF="../Body/f_pkg_sh.htm#package-shadowing-symbols"><B>package-shadowing-symbols</B></A><P>
(<A REL=DEFINITION HREF="../Body/f_find_p.htm#find-package"><B>find-package</B></A> 'test-1))))))<P>
<P>
(<A REL=DEFINITION HREF="../Body/f_mk_pkg.htm#make-package"><B>make-package</B></A> 'test-2)<P>
(<A REL=DEFINITION HREF="../Body/f_intern.htm#intern"><B>intern</B></A> &quot;TEST&quot; (<A REL=DEFINITION HREF="../Body/f_find_p.htm#find-package"><B>find-package</B></A> 'test-2))<P>
(<A REL=DEFINITION HREF="../Body/f_export.htm#export"><B>export</B></A> 'test-2::test (<A REL=DEFINITION HREF="../Body/f_find_p.htm#find-package"><B>find-package</B></A> 'test-2))<P>
(<A REL=DEFINITION HREF="../Body/f_use_pk.htm#use-package"><B>use-package</B></A> 'test-2 (<A REL=DEFINITION HREF="../Body/f_find_p.htm#find-package"><B>find-package</B></A> 'test-1)) ;should <A REL=DEFINITION HREF="../Body/a_not.htm#not"><B>not</B></A> <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>error</B></A><P>
<P>
;;; To test the use of strings in place of symbols<P>
;;; change the third line of the test case to<P>
;;; (shadow &quot;TEST&quot; (<A REL=DEFINITION HREF="../Body/f_find_p.htm#find-package"><B>find-package</B></A> 'test-1))<P>
;;; Note the use of capital letters in the string.<P>
<P>
<B>Rationale:<P>
</B><P>
CLtL p. 180 describes a name conflict problem that can occur when calling the<P>
function <A REL=DEFINITION HREF="../Body/f_use_pk.htm#use-package"><B>USE-PACKAGE</B></A>. The name conflict is between a symbol directly present in<P>
the using package and an external symbol of the used package. This name conflict<P>
may be resolved in favor of the symbol directly present in the using package by<P>
making it a shadowing symbol. For this to work, <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> must add the symbol to<P>
the <A REL=DEFINITION HREF="../Body/f_pkg_sh.htm#package-shadowing-symbols"><B>PACKAGE-SHADOWING-SYMBOLS</B></A> list even when it is already present in the<P>
package.<P>
<P>
Since only the print name of a symbol argument is meaningful, a string should<P>
also be accepted. This is particularly useful to avoid problems when compiling<P>
code in one package environment and loading it into a slightly different package<P>
environment, where the symbol that was referred to at compile time may not be<P>
present at load time. This is particularly important because the symbol<P>
referred to by the print name may be changed by evaluation of the <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> form.<P>
A close reading of CLtL shows that one can already use (shadow '#:bar) in place<P>
of (shadow 'bar), to achieve much the same effect as (shadow &quot;BAR&quot;). But the<P>
user should not have to play such games, strings should be accepted.<P>
<P>
<B>Current practice:<P>
</B><P>
Symbolics and Spice Lisp add the symbol to the <A REL=DEFINITION HREF="../Body/f_pkg_sh.htm#package-shadowing-symbols"><B>PACKAGE-SHADOWING-SYMBOLS</B></A> list,<P>
even when the symbol is already present in the package. Kyoto Common Lisp,<P>
Lucid Common Lisp, and Xerox Common Lisp ignore <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> when the symbol is<P>
already present in the package. It seems likely that we will find several<P>
implementations in each camp.<P>
<P>
<A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> accepts strings in Symbolics Common Lisp.<P>
<P>
<B>Cost to implementors:<P>
</B><P>
This should be a minor change to implementations that do not currently work this<P>
way.<P>
<P>
<B>Cost to users:<P>
</B><P>
Technically this would be an incompatible change to implementations that do not<P>
already behave as proposed, however it is difficult to conceive of a user<P>
program that would <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> any conversion to cope with the change. Some users<P>
might want to remove kludges that were only necessary to get around the former<P>
misbehavior of <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A>.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
Inconsistency among implementations and lack of a clear way to resolve the name<P>
conflict mentioned in Rationale.<P>
<P>
<B>Benefits:<P>
</B><P>
Consistency among implementations and fewer mysterious package problems.<P>
<P>
<B>Esthetics:<P>
</B><P>
The proposal would remove an unnecessary special case, thus simplifying the<P>
language slightly.<P>
<P>
<B>Discussion:<P>
</B><P>
The issue was raised by Dieter Kolb on the Common-Lisp mailing list.<P>
<P>
It would be useless for <A REL=DEFINITION HREF="../Body/f_shadow.htm#shadow"><B>SHADOW</B></A> to fail to put a symbol that is already present<P>
in the package onto the <A REL=DEFINITION HREF="../Body/f_pkg_sh.htm#package-shadowing-symbols"><B>PACKAGE-SHADOWING-SYMBOLS</B></A> list. Moon believes CLtL<P>
intended to describe what is being proposed, but unfortunately used ambiguous<P>
language.<P>
<P>
The cleanup committee endorses this proposal.<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>