1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss134_w.htm

116 lines
6.5 KiB
HTML
Raw Permalink Normal View History

2024-04-01 10:24:07 +02:00
<!-- 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 DO-SYMBOLS-DUPLICATES 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/iss133_w.htm">
<LINK REL=UP HREF="../Issues/iss134.htm">
<LINK REL=NEXT HREF="../Issues/iss135_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/iss133_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss134.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss135_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue DO-SYMBOLS-DUPLICATES Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss134.htm">DO-SYMBOLS-DUPLICATES</A><P>
<B>References:</B> <A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-symbols"><B>DO-SYMBOLS</B></A>, CLtL p.187<P>
<B>Category:</B> Clarification<P>
<B>Edit history:</B> Version 1 by Fahlman 17-Apr-87<P>
Version 2 by Masinter 29-May-87<P>
Version 3 by Masinter 23-Nov-87<P>
<P>
<B>Problem Description:<P>
</B><P>
CLtL specifies that <A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-symbols"><B>DO-SYMBOLS</B></A> executes the body once for each symbol<P>
accessible in the package. It does not say whether it is permissible<P>
for the body to be executed more than once for some accessible symbols.<P>
The term &quot;accessible&quot; is defined on page 172 to include symbols<P>
inherited from other packages (not including any symbols that may be<P>
shadowed). It is very expensive in some implementations to eliminate<P>
duplications that occur because the same symbol is inherited from<P>
multiple packages.<P>
<P>
Proposal: DO-SYMBOLS-DUPLICATES:ALLOWED<P>
<P>
Add to the specification of <A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-symbols"><B>DO-SYMBOLS</B></A> a note that it may execute the<P>
body more than once for some symbols.<P>
<P>
<B>Example:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/s_setq.htm#setq"><B>SETQ</B></A> A (<A REL=DEFINITION HREF="../Body/f_mk_pkg.htm#make-package"><B>MAKE-PACKAGE</B></A> 'A))<P>
(<A REL=DEFINITION HREF="../Body/s_setq.htm#setq"><B>SETQ</B></A> B (<A REL=DEFINITION HREF="../Body/f_mk_pkg.htm#make-package"><B>MAKE-PACKAGE</B></A> 'B))<P>
(<A REL=DEFINITION HREF="../Body/f_export.htm#export"><B>EXPORT</B></A> (<A REL=DEFINITION HREF="../Body/f_intern.htm#intern"><B>INTERN</B></A> &quot;ASYM&quot; A) A)<P>
(<A REL=DEFINITION HREF="../Body/f_use_pk.htm#use-package"><B>USE-PACKAGE</B></A> A B)<P>
(<A REL=DEFINITION HREF="../Body/f_export.htm#export"><B>EXPORT</B></A> 'B::ASYM B)<P>
(<A REL=DEFINITION HREF="../Body/f_use_pk.htm#use-package"><B>USE-PACKAGE</B></A> B A)<P>
(<A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-symbols"><B>DO-SYMBOLS</B></A> (X B) (<A REL=DEFINITION HREF="../Body/f_wr_pr.htm#print"><B>PRINT</B></A> X)) <P>
;; this may print ASYM once or twice.<P>
<P>
<B>Rationale:<P>
</B><P>
Most uses of DO-PACKAGE would not be harmed by the presence of<P>
duplicates. For these applications it is unreasonable to force users to<P>
pay the high cost of filtering out the duplications. Users who really<P>
want the duplicates to be removed can add additional code to do this job.<P>
<P>
<B>Current Practice:<P>
</B><P>
Many implementations have always produced duplicate values.<P>
<P>
<B>Cost to implementors:<P>
</B><P>
None. Implemenations would still be free to eliminate the duplications,<P>
though code will not be assuming that this has been done.<P>
<P>
<B>Cost to users:<P>
</B><P>
Code written assuming that <A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-symbols"><B>DO-SYMBOLS</B></A> eliminates duplications<P>
will have to be modified. (Such code was not truly portable.)<P>
<P>
<B>Benefits:<P>
</B><P>
Clarification of a situation that is currently ambiguous.<P>
<P>
<B>Aesthetics:<P>
</B><P>
It would be cleaner to present each symbol exactly once. This is a<P>
clear case of choosing efficiency over elegance.<P>
<P>
<B>Discussion:<P>
</B><P>
This issue was discussed on the Common Lisp mailing list in 1985, and<P>
the solution proposed here seems to have been informally agreed to at<P>
the time -- there was no formal decision-making process in place then.<P>
<P>
The need for <A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-symbols"><B>do-symbols</B></A> to be efficient is questionable, however; for <P>
many applications (e.g., global package manipulation), duplicate values<P>
would create havoc. <P>
<P>
For some implementations, the performance penalty would be well over <P>
a factor of two.<P>
<P>
Several proposals were considered for adding keyword arguments<P>
to <A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-symbols"><B>DO-SYMBOLS</B></A> which might specify :ALLOW-DUPLICATES, adding keywords<P>
and eliminating <A REL=DEFINITION HREF="../Body/m_do_sym.htm#do-external-symbols"><B>DO-EXTERNAL-SYMBOLS</B></A>, etc., but no clear consensus<P>
was reached for making additions.<P>
<P>
This version is the closest to the status quo.<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>