126 lines
6.8 KiB
HTML
126 lines
6.8 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 LOOP-AND-DISCREPANCY 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/iss219_w.htm">
|
||
|
<LINK REL=UP HREF="../Issues/iss220.htm">
|
||
|
<LINK REL=NEXT HREF="../Issues/iss221_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/iss219_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss220.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss221_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
|
||
|
<H2>Issue LOOP-AND-DISCREPANCY Writeup</H2>
|
||
|
|
||
|
<PRE><B>Issue:</B> <A HREF="iss220.htm">LOOP-AND-DISCREPANCY</A><P>
|
||
|
<P>
|
||
|
<B>References:</B> Loop Facility document X3J13/89-004<P>
|
||
|
<P>
|
||
|
<B>Related issues: <P>
|
||
|
</B><P>
|
||
|
<B>Category:</B> CHANGE CLARIFICATION<P>
|
||
|
<P>
|
||
|
<B>Edit history:</B> Version 1, 15-Mar-88 by Steele<P>
|
||
|
<P>
|
||
|
<B>Problem description:<P>
|
||
|
</B><P>
|
||
|
The treatment of the <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A> conjunction in FOR/AS and WITH clauses is not<P>
|
||
|
consistent. Examples of the use of WITH are also not consistent in this<P>
|
||
|
respect.<P>
|
||
|
<P>
|
||
|
Page 2-5 implies by example that when <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A> is used to join two<P>
|
||
|
FOR/AS clauses, the word FOR or AS must occur after the word <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A>.<P>
|
||
|
<P>
|
||
|
Page 2-31 has formal syntax specifying that when <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A> is used to join two<P>
|
||
|
WITH clauses, the word WITH must *not* occur after the word <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A>. Examples<P>
|
||
|
on that page are consistent with this specification.<P>
|
||
|
<P>
|
||
|
Page 2-41 has an example in which WITH is repeated after <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A>.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Proposal (LOOP-AND-DISCREPANCY:NO-REITERATION):<P>
|
||
|
</B><P>
|
||
|
Let stand the formal syntax for WITH.<P>
|
||
|
<P>
|
||
|
Change the description of FOR/AS clauses to specify that when<P>
|
||
|
two or more such clauses are joined with <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A>, clauses after the<P>
|
||
|
first do not have FOR or AS before them.<P>
|
||
|
<P>
|
||
|
The complete formal syntax for FOR/AS may be described as follows:<P>
|
||
|
<P>
|
||
|
for-as ::= {FOR | AS} for-as-subclause {AND for-as-subclause}*<P>
|
||
|
<P>
|
||
|
for-as-subclause ::= for-as-arithmetic | for-as-in-list<P>
|
||
|
| for-as-on-list | for-as-equals-then<P>
|
||
|
| for-as-across | for-as-hash | for-as-package<P>
|
||
|
<P>
|
||
|
for-as-arithmetic ::= var [type-spec] ...<P>
|
||
|
<P>
|
||
|
and so on.<P>
|
||
|
<P>
|
||
|
<B>Examples:<P>
|
||
|
</B><P>
|
||
|
> (loop for x from 1 to 10 ;Corrected from X3J13/89-004, page 2-5<P>
|
||
|
and y = nil then x<P>
|
||
|
collect (list x y))<P>
|
||
|
((1 <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>) (2 1) (3 2) (4 3) (5 4) (6 5) (7 6) (8 7) (9 8) (10 9))<P>
|
||
|
<P>
|
||
|
> (loop with (a b) float = '(1.0 2.0) ;Corrected from X3J13/89-004, page 2-41<P>
|
||
|
and (c d) integer = '(3 4)<P>
|
||
|
and (e f)<P>
|
||
|
return (list a b c d e f))<P>
|
||
|
(1.0 2.0 3 4 <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>nil</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>nil</B></A>)<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Rationale:<P>
|
||
|
</B><P>
|
||
|
The treatment of <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A> should be internally consistent. There is no reason<P>
|
||
|
to repeat the FOR/AS keyword. Not repeating the keyword emphasizes that<P>
|
||
|
the subclauses are functionally linked under the heading of WITH or FOR.<P>
|
||
|
(Compare to <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>the</B></A> <A REL=DEFINITION HREF="../Body/f_firstc.htm#third"><B>third</B></A> use of <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A> in <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A>, to link clauses controlled<P>
|
||
|
by WHEN/IF/UNLESS. One does <A REL=DEFINITION HREF="../Body/a_not.htm#not"><B>not</B></A> repeat <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>the</B></A> WHEN; rather, <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>the</B></A> clauses<P>
|
||
|
grouped by <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A> are controlled by a single <A REL=DEFINITION HREF="../Body/m_when_.htm#when"><B>WHEN</B></A>.)<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Current practice:<P>
|
||
|
</B><P>
|
||
|
Symbolics <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> allows FOR to be included or omitted after <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A>,<P>
|
||
|
with identical meanings. WITH may not be repeated after <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A>.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
Cost to Implementors: Small?<P>
|
||
|
<P>
|
||
|
Cost to Users: Possible incompatibility with existing implementors' extensions.<P>
|
||
|
<P>
|
||
|
Cost of non-adoption: Utter confusion.<P>
|
||
|
<P>
|
||
|
Performance impact: None.<P>
|
||
|
<P>
|
||
|
Benefits: Consistent treatment of <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>AND</B></A> within <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A>.<P>
|
||
|
<P>
|
||
|
<B>Esthetics:<P>
|
||
|
</B><P>
|
||
|
Absolutely none. We're talking about <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> here.<P>
|
||
|
<P>
|
||
|
<B>Discussion:<P>
|
||
|
</B><P>
|
||
|
Steele supports this proposal. It is a reversal of his previous<P>
|
||
|
suggestion on the topic, thanks to feedback from Moon.<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>
|