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

175 lines
11 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 ALLOW-OTHER-KEYS-NIL 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/iss007_w.htm">
<LINK REL=UP HREF="../Issues/iss008.htm">
<LINK REL=NEXT HREF="../Issues/iss009_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/iss007_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss008.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss009_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue ALLOW-OTHER-KEYS-NIL Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss008.htm">ALLOW-OTHER-KEYS-NIL</A><P>
<B>Forum:</B> Cleanup<P>
<B>References:</B> :ALLOW-OTHER-KEYS (pp62-63)<P>
<B>Category:</B> CLARIFICATION/CHANGE<P>
<B>Edit history:</B> 22-Aug-90, Version 1 by Pitman<P>
23-Aug-90, Version 2 by Pitman (merge RWK's comments)<P>
23-Aug-90, Version 3 by Pitman (merge Moon's comments)<P>
13-Mar-91, Version 4 by Pitman (comments from JonL, Barmar)<P>
<B>Status:</B> For Internal Discussion<P>
<P>
<B>Problem Description:<P>
</B><P>
CLtL specifies that a keyword argument pair of :ALLOW-OTHER-KEYS is<P>
always permissible when the value is non-null, in which case all other<P>
keyword arguments in that actual call are allowed regardless of the <P>
formal <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> parameter). It doesn't specify any particular meaning <P>
when the value for :ALLOW-OTHER-KEYS is null; consequently such an<P>
actual argument pair will be in error unless there is a formal <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A><P>
parameter of that name to receive it.<P>
<P>
The fact that :ALLOW-OTHER-KEYS <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> either does not work or does not<P>
work reliably causes some coding to be more cumbersome than necessary.<P>
For example, a function that might be written as:<P>
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> FOO-MEMBER (ITEM <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>LIST</B></A> PERMISSIVE-P <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&amp;REST</B></A> OPTIONS)<P>
(<A REL=DEFINITION HREF="../Body/f_apply.htm#apply"><B>APPLY</B></A> #'<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> ITEM <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>LIST</B></A> :ALLOW-OTHER-KEYS PERMISSIVE-P OPTIONS))<P>
must in fact be written as:<P>
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> FOO-MEMBER (ITEM <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>LIST</B></A> PERMISSIVE-P <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&amp;REST</B></A> OPTIONS)<P>
(<A REL=DEFINITION HREF="../Body/s_if.htm#if"><B>IF</B></A> PERMISSIVE-P<P>
(<A REL=DEFINITION HREF="../Body/f_apply.htm#apply"><B>APPLY</B></A> #'<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> ITEM <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>LIST</B></A> :ALLOW-OTHER-KEYS T OPTIONS)<P>
(<A REL=DEFINITION HREF="../Body/f_apply.htm#apply"><B>APPLY</B></A> #'<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> ITEM <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>LIST</B></A> OPTIONS)))<P>
because :ALLOW-OTHER-KEYS <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> is not given the `obvious' meaning.<P>
<P>
Some people have raised concerns about the permissibility and semantics<P>
of :ALLOW-OTHER-KEYS (including :ALLOW-OTHER-KEYS <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>) if either<P>
<A REL=DEFINITION HREF="../Body/03_da.htm#AMallow-other-keys"><B>&amp;ALLOW-OTHER-KEYS</B></A> is used or an explicit <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> argument such as<P>
ALLOW-OTHER-KEYS is specified. Some clarification about such issues<P>
is probably warranted.<P>
<P>
<B>Proposal (ALLOW-OTHER-KEYS-NIL:PERMIT):<P>
</B><P>
1. Define that :ALLOW-OTHER-KEYS is always permitted as an argument<P>
to any function which has specified <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> in the <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list of its<P>
definition.<P>
<P>
If the value is non-NIL, then other non-matching keywords are<P>
also tolerated (i.e., ignored). If the value is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, then other <P>
non-matching keyword are not tolerated (i.e., an error should be<P>
signalled in accordance with rules for argument mismatches <P>
established by other proposals) unless <A REL=DEFINITION HREF="../Body/03_da.htm#AMallow-other-keys"><B>&amp;ALLOW-OTHER-KEYS</B></A> was used.<P>
<P>
2. Clarify that if the receiving argument list specifies an argument which <P>
would be flagged by :ALLOW-OTHER-KEYS, then :ALLOW-OTHER-KEYS has both <P>
its special-cased meaning (identifying whether additional keywords are <P>
permitted) and its normal meaning (data flow into the function in <P>
question).<P>
<P>
<B>Rationale:<P>
</B><P>
1. There can't be any reasonable use for :ALLOW-OTHER-KEYS as a keyword<P>
to designate `real' information coming into the function since the <P>
keyword is already reserved just in case the value it carries with<P>
it will be non-NIL. As such, there is no ambiguity about the<P>
programmer's intent in the case of :ALLOW-OTHER-KEYS <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. Failing<P>
to admit :ALLOW-OTHER-KEYS <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> just makes it unnecessarily clumsy<P>
to write functions like FOO-MEMBER (see Problem Description).<P>
It also defeats the purpose of there being a value associated with<P>
:ALLOW-OTHER-KEYS in the first place.<P>
<P>
2. This allows functions which do their own keyword processing on <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&amp;REST</B></A><P>
arguments to respect this flag, as well as being conceptually the most<P>
uniform meaning.<P>
<P>
<B>Test Case:<P>
</B><P>
#1: ((<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (<A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A>) T) :ALLOW-OTHER-KEYS <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>)<P>
<P>
#2: (<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> FOO-MEMBER (ITEM <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>LIST</B></A> PERMISSIVE-P <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&amp;REST</B></A> OPTIONS)<P>
(<A REL=DEFINITION HREF="../Body/f_apply.htm#apply"><B>APPLY</B></A> #'<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>MEMBER</B></A> ITEM <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>LIST</B></A> :ALLOW-OTHER-KEYS PERMISSIVE-P OPTIONS))<P>
(FOO-MEMBER 'X '(Z Y X) <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>)<P>
<P>
#3: ((<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (<A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> ALLOW-OTHER-KEYS) ALLOW-OTHER-KEYS)<P>
:ALLOW-OTHER-KEYS 6 :FRED 7)<P>
<P>
#4: ((<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (<A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> ALLOW-OTHER-KEYS) ALLOW-OTHER-KEYS)<P>
:ALLOW-OTHER-KEYS <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> :FRED 7)<P>
<P>
#5: ((<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (<A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> ((:ALLOW-OTHER-KEYS FOO))) FOO)<P>
:ALLOW-OTHER-KEYS 6 :FRED 7)<P>
<P>
<B>Current Practice:<P>
</B><P>
#1: Symbolics Genera 8.0 and Sun Common Lisp 3.0.1 signal an error.<P>
Symbolics Genera 8.1 returns T, which is consistent with proposal <P>
PERMIT.<P>
<P>
#2: Symbolics Genera 8.0 and Sun Common Lisp 3.0.1 signal an error.<P>
Symbolics Genera 8.1 returns (X), which is consistent with proposal<P>
PERMIT.<P>
<P>
#3: Sun Common Lisp 3.0.1 signals an error.<P>
Symbolics Genera 8.0 and 8.1 return 6, which is consistent with <P>
proposal PERMIT.<P>
<P>
#4: Symbolics Genera 8.0, Symbolics Genera 8.1, and Sun Common Lisp 3.0.1<P>
signal an error, which is consistent with proposal PERMIT.<P>
<P>
#5: Sun Common Lisp 3.0.1 signals an error.<P>
Symbolics Genera 8.0 and 8.1 return 6, which is consistent with<P>
proposal PERMIT.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
Relatively small.<P>
<P>
<B>Cost to Users:<P>
</B><P>
None. Currently, a valid user program must avoid stepping on this<P>
error situation.<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
See aesthetics.<P>
<P>
<B>Benefits:<P>
</B><P>
See aesthetics.<P>
<P>
<B>Aesthetics:<P>
</B><P>
This simplifies the user model by making the value associated with<P>
:ALLOW-OTHER-KEYS be what controls whether other keys are permitted,<P>
rather than by making the presence of the sequence ``:ALLOW-OTHER-KEYS T''<P>
in the arglist what controls it. In the status quo, the description of<P>
how :ALLOW-OTHER-KEYS works is like no other keyword in the language.<P>
<P>
<B>Discussion:<P>
</B><P>
Pitman, RWK, and Moon support this proposal.<P>
<P>
RWK comments: ``Together with my addenda above, [this] proposal <P>
means that <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> without <A REL=DEFINITION HREF="../Body/03_da.htm#AMallow-other-keys"><B>&amp;ALLOW-OTHER-KEYS</B></A> implies a &quot;hidden&quot; <P>
keyword argument of :ALLOW-OTHER-KEYS that the <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> processing <P>
checks. In all other regards, it is a perfectly ordinary keyword <P>
argument.''<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>