145 lines
9.3 KiB
HTML
145 lines
9.3 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-NAMED-BLOCK-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/iss223_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss224.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss225_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/iss223_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss224.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss225_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue LOOP-NAMED-BLOCK-NIL Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> Proposal OVERRIDE (version 2) accepted 12/91<P>
|
|
<B>Issue:</B> <A HREF="iss224.htm">LOOP-NAMED-BLOCK-NIL</A><P>
|
|
Reference: Draft 9.126<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit History:</B> Version 1, 22-Dec-91, Kim Barrett<P>
|
|
Version 2, 26-Jan-92, Kim Barrett (clarification, per KMP)<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
(Note: All section numbers are from Draft 9.126)<P>
|
|
<P>
|
|
Regarding:<P>
|
|
<P>
|
|
section 8.1.2.2, page 8-2, last paragraph in section<P>
|
|
<P>
|
|
Expansion of the \macref{loop} macro produces an implicit block named \nil\<P>
|
|
unless \loop{named} is supplied. Thus, \macref{return} and<P>
|
|
\specref{return-from} can be used to return values from \macref{loop} or to<P>
|
|
exit \macref{loop}.<P>
|
|
<P>
|
|
section 8.1.2.6, End-Test Control, p8-15, first itemization<P>
|
|
<P>
|
|
\itemitem{\bull} The \loop{until} construct executes any \loop{finally}<P>
|
|
clause. Since \loop{thereis} uses the macro \macref{return} to terminate<P>
|
|
iteration, any \loop{finally} clause that is supplied is not evaluated. <P>
|
|
<P>
|
|
section 8.1.2.6, End-Test Control, p8-15, second itemization<P>
|
|
<P>
|
|
\itemitem{\bull} The \loop{until} construct executes any \loop{finally}<P>
|
|
clause. Since \loop{never} uses the macro \macref{return} to terminate<P>
|
|
iteration, any \loop{finally} clause that is supplied is not evaluated. <P>
|
|
<P>
|
|
In his review, Barmar noted "hmm..." in regard to this issue of not having a<P>
|
|
<A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> block get generated even when NAMED is used. He and KMP discussed it and<P>
|
|
decided (based on examining the Lucid and Symbolics implementations) that the<P>
|
|
intent was clear and they would let it go.<P>
|
|
<P>
|
|
In processing other review comments of Barmar's, KMP noticed that these two<P>
|
|
items refer specifically to <A REL=DEFINITION HREF="../Body/m_return.htm#return"><B>RETURN</B></A> (rather than <A REL=DEFINITION HREF="../Body/s_ret_fr.htm#return-from"><B>RETURN-FROM</B></A>) being generated.<P>
|
|
This suggests one of the following two things:<P>
|
|
<P>
|
|
(a) <A REL=DEFINITION HREF="../Body/m_return.htm#return"><B>RETURN</B></A> was not intended in the second two cases, and <A REL=DEFINITION HREF="../Body/s_ret_fr.htm#return-from"><B>RETURN-FROM</B></A> was<P>
|
|
meant.<P>
|
|
<P>
|
|
(b) <A REL=DEFINITION HREF="../Body/m_return.htm#return"><B>RETURN</B></A> was intended intended in the second two, and this exposes the fact<P>
|
|
that the part about having no <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> block in the first case was wrong.<P>
|
|
<P>
|
|
How shall we proceed in fixing this?<P>
|
|
<P>
|
|
<B>Proposal (LOOP-NAMED-BLOCK-NIL:OVERRIDE):<P>
|
|
</B><P>
|
|
Clarify that if a NAMED clause appears in a <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> form then no implicit <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A><P>
|
|
block is established by the <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> form. That is, confirm interpretation (a)<P>
|
|
and reject interpretation (b) from the Problem Description.<P>
|
|
<P>
|
|
<B>Editorial Impact:<P>
|
|
</B><P>
|
|
The two bulleted items mentioned in the problem description need to be changed<P>
|
|
to refer to the special operator <A REL=DEFINITION HREF="../Body/s_ret_fr.htm#return-from"><B>RETURN-FROM</B></A> rather than the macro <A REL=DEFINITION HREF="../Body/m_return.htm#return"><B>RETURN</B></A>.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
Gives the user greater control over the expansion of a <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> form, permitting<P>
|
|
its use in places where it might not be desirable if a <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> block were always<P>
|
|
established.<P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
(<A REL=DEFINITION HREF="../Body/s_block.htm#block"><B>block</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>nil</B></A><P>
|
|
(<A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>loop</B></A> named foo<P>
|
|
<A REL=DEFINITION HREF="../Body/m_do_do.htm#do"><B>do</B></A> (<A REL=DEFINITION HREF="../Body/m_return.htm#return"><B>return</B></A> 'success))<P>
|
|
'failure)<P>
|
|
-> SUCCESS<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Apple MCL 2.0b3 and Lucid 4.0 do not introduce an implicit <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> block if a <P>
|
|
NAMED clause is present in the <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> form.<P>
|
|
<P>
|
|
Symbolics <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> always introduces a <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> block, in addition to any block<P>
|
|
established for a NAMED clause.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Barrett:<P>
|
|
I think (a) (<A REL=DEFINITION HREF="../Body/s_ret_fr.htm#return-from"><B>RETURN-FROM</B></A> was meant, rather than <A REL=DEFINITION HREF="../Body/m_return.htm#return"><B>RETURN</B></A>) is preferable. The<P>
|
|
main use I've found for explicitly named blocks is to avoid accidentally<P>
|
|
shadowing the intended receiver of a <A REL=DEFINITION HREF="../Body/s_ret_fr.htm#return-from"><B>return-from</B></A> when writing a wrapper<P>
|
|
macro. If <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> might always introduce a <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> block then you can't safely<P>
|
|
write such macros in terms of <A REL=DEFINITION HREF="../Body/m_loop.htm#loop"><B>LOOP</B></A> forms.<P>
|
|
<P>
|
|
GSB:<P>
|
|
I'm not sure how much help this is; I'll try to explain the history behind<P>
|
|
the current Symbolics implementation.<P>
|
|
<P>
|
|
My personal preference is for NAMED to use the named block instead of<P>
|
|
(rather than in addition to) a block named <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. Now, at the time I<P>
|
|
implemented the ANSI loop (and extensions) at Symbolics, I was under the<P>
|
|
impression that NAMED was not part of ANSI. Maybe it had been dyked from<P>
|
|
the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>, maybe it was in the process of being removed (there was this<P>
|
|
minimalist pressure at the time). JonL, you remember anything about this?<P>
|
|
I was basically working from the first draft that differed greatly from the<P>
|
|
prior Lucid documentation.<P>
|
|
<P>
|
|
Now, a semantic divergence occurred several years ago between the "NIL" and<P>
|
|
other "MIT" loop sources, and the Symbolics Zetalisp loop source, because<P>
|
|
someone (Me) got confused about the semantics of Zetalisp's named <A REL=DEFINITION HREF="../Body/m_prog_.htm#prog"><B>PROG</B></A>. In<P>
|
|
particular, I translated (prog name varlist ...) into roughly<P>
|
|
(block name (let varlist (<A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>tagbody</B></A> ...))). This is not a correct<P>
|
|
translation: Zetalisp named prog establishes that block name IN ADDITION TO<P>
|
|
a block named <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. Therefore when I did NAMED (as an extension to ANSI), I<P>
|
|
made it compatible with the existing (lisp machine) one, against my own<P>
|
|
preferences, because it was only an extension and the incompatibility is<P>
|
|
fairly subtle.<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>
|