122 lines
6.6 KiB
HTML
122 lines
6.6 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 PUSHNEW-STORE-REQUIRED 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/iss279_w.htm">
|
||
|
<LINK REL=UP HREF="../Issues/iss281.htm">
|
||
|
<LINK REL=NEXT HREF="../Issues/iss282_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/iss279_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss281.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss282_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
|
||
|
<H2>Issue PUSHNEW-STORE-REQUIRED Writeup</H2>
|
||
|
|
||
|
<PRE><B>Issue:</B> <A HREF="iss281.htm">PUSHNEW-STORE-REQUIRED</A><P>
|
||
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A><P>
|
||
|
Related issues: <A HREF="iss279_m.htm">PUSH-EVALUATION-ORDER</A><P>
|
||
|
<A HREF="iss306.htm">SETF-GET-DEFAULT</A><P>
|
||
|
<B>Category:</B> CLARIFICATION<P>
|
||
|
<B>Edit history:</B> v1, 14 Feb 1991, Sandra Loosemore<P>
|
||
|
v2, 26 Mar 1991, Sandra Loosemore (amendment from meeting)<P>
|
||
|
<B>Status:</B> v2 (proposal UNSPECIFIED) accepted by X3J13, Mar 1991<P>
|
||
|
<P>
|
||
|
<B>Problem description:<P>
|
||
|
</B><P>
|
||
|
The description of the <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> macro says contradictory things about<P>
|
||
|
whether the storing form for its place subform must or must not be <P>
|
||
|
evaluated in the situation where the <item> is already a member of<P>
|
||
|
the list.<P>
|
||
|
<P>
|
||
|
In CLtL, <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> is first described as:<P>
|
||
|
<P>
|
||
|
If the <item> is not already a member of the list (...), then the <P>
|
||
|
<item> is consed onto the front of the list, and the augmented list is<P>
|
||
|
stored back into <place> and returned; otherwise the unaugmented list<P>
|
||
|
is returned.<P>
|
||
|
<P>
|
||
|
This passage implies that <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> is effectively (modulo order of<P>
|
||
|
evaluation issues and keyword arguments): <P>
|
||
|
<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/s_if.htm#if"><B>if</B></A> (<A REL=DEFINITION HREF="../Body/a_not.htm#not"><B>not</B></A> (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>member</B></A> <item> <place>))<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> <place> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>cons</B></A> <item> <place>))<P>
|
||
|
<place>)<P>
|
||
|
<P>
|
||
|
which executes the storing form for <place> only if the member test<P>
|
||
|
fails.<P>
|
||
|
<P>
|
||
|
However, later on it's said that <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> is effectively (again modulo<P>
|
||
|
order of evaluation issues and keyword arguments):<P>
|
||
|
<P>
|
||
|
(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> <place> (<A REL=DEFINITION HREF="../Body/f_adjoin.htm#adjoin"><B>adjoin</B></A> <item> <place>))<P>
|
||
|
<P>
|
||
|
which executes the storing form for <place> unconditionally.<P>
|
||
|
<P>
|
||
|
So which of these two models for its expansion is correct?<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Proposal (PUSHNEW-STORE-REQUIRED:UNSPECIFIED):<P>
|
||
|
</B><P>
|
||
|
Clarify that it is not specified whether <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> executes the storing<P>
|
||
|
form for its <place> subform in the situation where the <item> is<P>
|
||
|
already a member of the list.<P>
|
||
|
<P>
|
||
|
<B>Rationale:<P>
|
||
|
</B><P>
|
||
|
The store operation might be expensive and there's no point in doing<P>
|
||
|
it if the value being stored hasn't changed. On the other hand, in<P>
|
||
|
some implementations <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> always does the store.<P>
|
||
|
<P>
|
||
|
<B>Current Practice:<P>
|
||
|
</B><P>
|
||
|
In both Lucid and Allegro, <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> always does the store.<P>
|
||
|
<P>
|
||
|
<B>Cost to Implementors:<P>
|
||
|
</B><P>
|
||
|
None. No implementation is required to change.<P>
|
||
|
<P>
|
||
|
<B>Cost to Users:<P>
|
||
|
</B><P>
|
||
|
Probably none. <P>
|
||
|
<P>
|
||
|
<B>Cost of non-adoption:<P>
|
||
|
</B><P>
|
||
|
The description of <A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> is confusing.<P>
|
||
|
<P>
|
||
|
<B>Performance impact:<P>
|
||
|
</B><P>
|
||
|
Not doing the store when it's not necessary can speed things up.<P>
|
||
|
<P>
|
||
|
<B>Benefits:<P>
|
||
|
</B><P>
|
||
|
The cost of non-adoption is avoided.<P>
|
||
|
<P>
|
||
|
<B>Esthetics:<P>
|
||
|
</B><P>
|
||
|
<A REL=DEFINITION HREF="../Body/m_pshnew.htm#pushnew"><B>PUSHNEW</B></A> would be less confusing if we could just agree on one or <P>
|
||
|
the other of the two models as being correct and remove all mention<P>
|
||
|
of the other from its description in the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>.<P>
|
||
|
<P>
|
||
|
<B>Discussion:<P>
|
||
|
</B><P>
|
||
|
There is a potential for generalization to other read-modify-write <P>
|
||
|
macros. See the discussion section of issue <A HREF="iss306.htm">SETF-GET-DEFAULT</A>.<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>
|