188 lines
14 KiB
HTML
188 lines
14 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 DEFMACRO-LAMBDA-LIST 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/iss105_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss106.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss107_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/iss105_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss106.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss107_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue DEFMACRO-LAMBDA-LIST Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> Passed, as amended, Mar 89 X3J13<P>
|
|
<B>Issue:</B> <A HREF="iss106.htm">DEFMACRO-LAMBDA-LIST</A><P>
|
|
<B>Forum:</B> Cleanup<P>
|
|
<B>References:</B> 8.1 Macro Definition (CLtL pp144-151),<P>
|
|
Issue <A REL=DEFINITION HREF="../Body/m_destru.htm#destructuring-bind"><B>DESTRUCTURING-BIND</B></A><P>
|
|
<B>Category:</B> CLARIFICATION/CHANGE<P>
|
|
<B>Edit history:</B> 30-Jan-89, Version 1 by Pitman<P>
|
|
17-Mar-89, Version 2 by Masinter<P>
|
|
9-Apr-89, Version 3 by Masinter <P>
|
|
Incorporate amendments as per Mar 89 X3J13<P>
|
|
10-Apr-89, V.4 Masinter (forgot an amendment)<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
The description of the <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list currently contains some <P>
|
|
mis-statements and leaves some ambiguities:<P>
|
|
<P>
|
|
1. Can <A REL=DEFINITION HREF="../Body/03_dd.htm#AMbody"><B>&BODY</B></A>, <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A>, and <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> appear at recursive levels of the<P>
|
|
<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list?<P>
|
|
<P>
|
|
The description of <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> (p145) specifies that <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> must occur ``first<P>
|
|
in the <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list,'' but the description of a <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list says that <P>
|
|
``a <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> may [recursively] appear in place of the parameter name.''<P>
|
|
Consequently, the question arises whether <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> should be permitted to<P>
|
|
be a synonym for <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A> at inner levels of a <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list.<P>
|
|
<P>
|
|
The descriptions of <A REL=DEFINITION HREF="../Body/03_dd.htm#AMbody"><B>&BODY</B></A> and <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> do not contain syntactic<P>
|
|
restrictions on where they may appear.<P>
|
|
<P>
|
|
2. Does using <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> affect the pattern of arguments permitted by <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A>.<P>
|
|
<P>
|
|
<B>Proposal (DEFMACRO-LAMBDA-LIST:TIGHTEN-DESCRIPTION):<P>
|
|
</B><P>
|
|
1. a. Specify that <A REL=DEFINITION HREF="../Body/03_dd.htm#AMbody"><B>&BODY</B></A> may appear at any level of a <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list.<P>
|
|
<P>
|
|
b. Specify that <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> may appear at any level of a <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A><P>
|
|
<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list. At inner levels, the <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> variable is bound to<P>
|
|
the corresponding part of the argument, as with <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A>, but<P>
|
|
unlike <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A>, other arguments are also allowed.<P>
|
|
<P>
|
|
c. Specify that <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> may only appear at the top level of a<P>
|
|
<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list.<P>
|
|
<P>
|
|
2. Clarify that using <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> does not affect the pattern of arguments<P>
|
|
specified by <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A>.<P>
|
|
<P>
|
|
3. Clarify that <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> may appear anywhere in the top level<P>
|
|
of a <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list, as in the following examples:<P>
|
|
<P>
|
|
(&whole W &environment E A B) ``After &Whole''<P>
|
|
(&environment E &whole W A B) ``Before &Whole''<P>
|
|
(&whole W A B &environment E) ``Last''<P>
|
|
(&whole W A &environment E B) ``Middle''<P>
|
|
<P>
|
|
4. <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> can only appear once in a <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list.<P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
1. (<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM1A (<A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> FORM A B) ...) is defined.<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM1B (A (<A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> B C <A REL=DEFINITION HREF="../Body/03_da.htm#AMoptional"><B>&OPTIONAL</B></A> D) E) ...) is defined.<P>
|
|
It allows simultaneousaccess to the <A REL=DEFINITION HREF="../Body/f_firstc.htm#third"><B>THIRD</B></A> of the whole<P>
|
|
form as B and to the destructuring of that list into<P>
|
|
C and D.<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM1C (A B <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> ENV) ...) is defined.<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM1D (A (B <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> ENV) C) ...) is undefined.<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM1E (A B <A REL=DEFINITION HREF="../Body/03_dd.htm#AMbody"><B>&BODY</B></A> X) ...) is defined.<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM1F (A (B <A REL=DEFINITION HREF="../Body/03_dd.htm#AMbody"><B>&BODY</B></A> X) C) ...) is defined.<P>
|
|
<P>
|
|
2. (<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM2A (<A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> X) `',X)<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> '(DM2A)) => (<A REL=DEFINITION HREF="../Body/s_quote.htm#quote"><B>QUOTE</B></A> (DM2A))<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> '(DM2A A)) is an error.<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> DM2B (<A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> X A <A REL=DEFINITION HREF="../Body/03_da.htm#AMoptional"><B>&OPTIONAL</B></A> B) `'(,X ,A ,B))<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> '(DM2B)) is an error.<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> '(DM2B Q)) => (<A REL=DEFINITION HREF="../Body/s_quote.htm#quote"><B>QUOTE</B></A> ((DM2B Q) Q <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>))<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> '(DM2B Q R)) => (<A REL=DEFINITION HREF="../Body/s_quote.htm#quote"><B>QUOTE</B></A> ((DM2B Q R) Q R))<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> '(DM2B Q R S)) is an error.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
1. a. An example on p151 makes it clear that this was the intent.<P>
|
|
<P>
|
|
b. There's no cogent reason to forbid <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> at inner levels.<P>
|
|
The example on p.150 uses <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> in a non-top-level position.<P>
|
|
<P>
|
|
This simplifies the implementation of <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> if we introduce a<P>
|
|
<A REL=DEFINITION HREF="../Body/m_destru.htm#destructuring-bind"><B>DESTRUCTURING-BIND</B></A> which does not understand <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A>.<P>
|
|
<P>
|
|
c. The environment is never different at top level than embedded.<P>
|
|
Permitting <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> to occur embedded would only encourage<P>
|
|
the misconception that there was a potential difference.<P>
|
|
<P>
|
|
This simplifies the implementation of <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> if we introduce a<P>
|
|
<A REL=DEFINITION HREF="../Body/m_destru.htm#destructuring-bind"><B>DESTRUCTURING-BIND</B></A> which does not understand <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A>.<P>
|
|
<P>
|
|
2. This allows useful syntax checking.<P>
|
|
<P>
|
|
One can always trivially write<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> ... (<A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> FORM <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A> <A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A>) ...)<P>
|
|
to get around the error checking this forces.<P>
|
|
<P>
|
|
3. <vote at Mar 89 X3J13><P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
1. a. Symbolics Genera permits <A REL=DEFINITION HREF="../Body/03_dd.htm#AMbody"><B>&BODY</B></A> at any level. This is compatible.<P>
|
|
b. Symbolics Genera seems to permit <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> at any level. When embedded,<P>
|
|
it is treated as a synonym for <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A>. <P>
|
|
c. Symbolics Genera does not permit <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> except at top level.<P>
|
|
This is compatible.<P>
|
|
<P>
|
|
2. Symbolics Genera has this behavior when <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> appears at top level,<P>
|
|
but not at recursive levels (where <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> is treated as a synonym for<P>
|
|
<A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A>).<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
This seems to be what CLtL intended and what most implementations<P>
|
|
perform.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
We think this is possibly (probably) upward compatible with most<P>
|
|
current practice.<P>
|
|
<P>
|
|
<B>Cost of Non-Adoption:<P>
|
|
</B><P>
|
|
Some fuzzy places in <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> continue to exist.<P>
|
|
<P>
|
|
It's harder to introduce <A REL=DEFINITION HREF="../Body/m_destru.htm#destructuring-bind"><B>DESTRUCTURING-BIND</B></A> because describing its relation<P>
|
|
to <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> is difficult.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
The language is a little tighter.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
Negligible impact.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Part 2 of this issue came up during the discussion of <A HREF="iss139.htm">DOTTED-MACRO-FORMS</A><P>
|
|
but was not pursued until now.<P>
|
|
<P>
|
|
Pitman supports these clarifications.<P>
|
|
<P>
|
|
A previous version disallowed <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> at inner levels, because<P>
|
|
of the mistaken impression that <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> was equivalent to <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A>.<P>
|
|
However, additional arguments are not allowed after <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&REST</B></A>,<P>
|
|
while they are for <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A>.<P>
|
|
<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>
|