105 lines
7.1 KiB
HTML
105 lines
7.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 ASSOC-RASSOC-IF-KEY 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/iss016_w.htm">
|
||
|
<LINK REL=UP HREF="../Issues/iss017_m.htm">
|
||
|
<LINK REL=NEXT HREF="../Issues/iss019_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/iss016_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss017_m.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss019_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
|
||
|
<H2>Issue ASSOC-RASSOC-IF-KEY Writeup</H2>
|
||
|
|
||
|
<PRE><B>Issue:</B> <A HREF="iss017_m.htm">ASSOC-RASSOC-IF-KEY</A><P>
|
||
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if"><B>ASSOC-IF</B></A> (p280), <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if-not"><B>ASSOC-IF-NOT</B></A> (p280), <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if"><B>RASSOC-IF</B></A> (p281),<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if-not"><B>RASSOC-IF-NOT</B></A> (p281)<P>
|
||
|
<B>Category:</B> ENHANCEMENT<P>
|
||
|
<B>Edit history:</B> 22-Apr-87, Version 1 by Pitman<P>
|
||
|
20-Nov-87, Versions 2,3 by Masinter<P>
|
||
|
23-Nov-87, Version 4 by Masinter<P>
|
||
|
<P>
|
||
|
<B>Problem Description:<P>
|
||
|
</B><P>
|
||
|
The descriptions of <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if"><B>ASSOC-IF</B></A>, <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if-not"><B>ASSOC-IF-NOT</B></A>, <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if"><B>RASSOC-IF</B></A>, and <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if-not"><B>RASSOC-IF-NOT</B></A> do not<P>
|
||
|
mention a :KEY option, although <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc"><B>ASSOC</B></A> and <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc"><B>RASSOC</B></A> have one. <P>
|
||
|
<P>
|
||
|
This is often reported as an inconsistency in Common Lisp.<P>
|
||
|
<P>
|
||
|
<B>Proposal (ASSOC-RASSOC-IF-KEY:YES):<P>
|
||
|
</B><P>
|
||
|
Allow a :KEY keyword for <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if"><B>ASSOC-IF</B></A>, <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if-not"><B>ASSOC-IF-NOT</B></A>, <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if"><B>RASSOC-IF</B></A>, and <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if-not"><B>RASSOC-IF-NOT</B></A>.<P>
|
||
|
If not supplied, it should default to #'<A REL=DEFINITION HREF="../Body/f_identi.htm#identity"><B>IDENTITY</B></A> as do the :KEY keywords for<P>
|
||
|
other -IF and -IF-NOT functions. The function, as with the :KEY argument for<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc"><B>ASSOC</B></A> and <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc"><B>RASSOC</B></A>, is applied to the <A REL=DEFINITION HREF="../Body/f_car_c.htm#car"><B>CAR</B></A> of the pair in the association list for<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if"><B>ASSOC-IF</B></A> and <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if-not"><B>ASSOC-IF-NOT</B></A> and the <A REL=DEFINITION HREF="../Body/f_car_c.htm#cdr"><B>CDR</B></A> of the pair for <A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if"><B>RASSOC-IF</B></A> and<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_rassoc.htm#rassoc-if-not"><B>RASSOC-IF-NOT</B></A>.<P>
|
||
|
<P>
|
||
|
<B>Documentation impact:<P>
|
||
|
</B><P>
|
||
|
A better description of the intent might be to say that the <A REL=DEFINITION HREF="../Body/f_car_c.htm#car"><B>car</B></A> /contains/ the<P>
|
||
|
key of the association, and by default the <A REL=DEFINITION HREF="../Body/f_car_c.htm#car"><B>car</B></A> /is/ the key of the association.<P>
|
||
|
<P>
|
||
|
<B>Example:<P>
|
||
|
</B><P>
|
||
|
(<A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc-if"><B>assoc-if</B></A> #'<A REL=DEFINITION HREF="../Body/f_zerop.htm#zerop"><B>zerop</B></A> pathnames :key #'<A REL=DEFINITION HREF="../Body/f_pn_hos.htm#pathname-version"><B>pathname-version</B></A>)<P>
|
||
|
<P>
|
||
|
could be used to search a list indexed by pathnames finding one with zero<P>
|
||
|
version. <P>
|
||
|
<P>
|
||
|
<B>Rationale:<P>
|
||
|
</B><P>
|
||
|
This is an inconsistency in the language that is simple to fix.<P>
|
||
|
<P>
|
||
|
<B>Current Practice:<P>
|
||
|
</B><P>
|
||
|
Symbolics implements :KEY for the -IF and -IF-NOT <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc"><B>assoc</B></A> functions. Others follow<P>
|
||
|
the book and allow :KEY only for <A REL=DEFINITION HREF="../Body/f_assocc.htm#assoc"><B>ASSOC</B></A>.<P>
|
||
|
<P>
|
||
|
<B>Cost to Common Lisp implementors:<P>
|
||
|
</B><P>
|
||
|
A small amount of additional code is necessary to support this in<P>
|
||
|
implementations not already offering it as an extension.<P>
|
||
|
<P>
|
||
|
<B>Cost to Common Lisp users:<P>
|
||
|
</B><P>
|
||
|
The change is essentially upward compatible with user code.<P>
|
||
|
<P>
|
||
|
<B>Benefits:<P>
|
||
|
</B><P>
|
||
|
This would make the set of -IF and -IF-NOT functions be more regular in their<P>
|
||
|
calling conventions.<P>
|
||
|
<P>
|
||
|
<B>Aesthetics:<P>
|
||
|
</B><P>
|
||
|
All the other -IF and -IF-NOT variations of list operations omit the :TEST and<P>
|
||
|
:TEST-NOT keywords, but allow :KEY. For example, consider the family of <A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A>,<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_mem_m.htm#member-if"><B>MEMBER-IF</B></A>, and <A REL=DEFINITION HREF="../Body/f_mem_m.htm#member-if-not"><B>MEMBER-IF-NOT</B></A>. Although this introduces additional mechanism, it<P>
|
||
|
does so in a way that probably makes it easier to think about which functions do<P>
|
||
|
what, so it would likely be seen as a simplification.<P>
|
||
|
<P>
|
||
|
<B>Discussion:<P>
|
||
|
</B><P>
|
||
|
The omission of :KEY in this situation in CLtL was probably an oversight.<P>
|
||
|
<P>
|
||
|
The cleanup committee supports 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>
|