139 lines
8.3 KiB
HTML
139 lines
8.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 TAGBODY-TAG-EXPANSION 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/iss342_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss343.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss344_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/iss342_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss343.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss344_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue TAGBODY-TAG-EXPANSION Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss343.htm">TAGBODY-TAG-EXPANSION</A><P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>TAGBODY</B></A> (CLtL-II p 173-175)<P>
|
|
<B>Related issues:<P>
|
|
</B><B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit history:</B> v1, 27 Feb 91, Sandra Loosemore<P>
|
|
v2, 11 Mar 91, Sandra Loosemore (update discussion)<P>
|
|
v3, 14 Mar 91, Sandra Loosemore (fix bug in example)<P>
|
|
<B>Status:</B> v3 (proposal NO) accepted by X3J13, Mar 1991<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
It's not clear whether items in the body of a <A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>TAGBODY</B></A> are <P>
|
|
macroexpanded before determining whether they are "tags" or<P>
|
|
"statements". The (original) text on p. 173 of CLtL-II seems to <P>
|
|
imply that they are not, but the (new) commentary on p. 175 <P>
|
|
hints that some implementations might expand macros. This ambiguity<P>
|
|
can lead to different behavior in different implementations.<P>
|
|
<P>
|
|
<B>Proposal (TAGBODY-TAG-EXPANSION:NO):<P>
|
|
</B><P>
|
|
Clarify items in the body of a <A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>TAGBODY</B></A> are not macroexpanded in <P>
|
|
determining whether they are "tags" or "statements". <P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
#1: (<A REL=DEFINITION HREF="../Body/s_flet_.htm#macrolet"><B>macrolet</B></A> ((foo-macro () 'foo))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>let</B></A> ((<A REL=DEFINITION HREF="../Body/f_countc.htm#count"><B>count</B></A> 0) (foo <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>nil</B></A>))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>tagbody</B></A><P>
|
|
(foo-macro)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_when_.htm#when"><B>when</B></A> (< <A REL=DEFINITION HREF="../Body/f_countc.htm#count"><B>count</B></A> 5) (<A REL=DEFINITION HREF="../Body/m_incf_.htm#incf"><B>incf</B></A> <A REL=DEFINITION HREF="../Body/f_countc.htm#count"><B>count</B></A>) (<A REL=DEFINITION HREF="../Body/s_go.htm#go"><B>go</B></A> foo)))))<P>
|
|
<P>
|
|
This example is in error because (FOO-MACRO) is treated as a "statement" <P>
|
|
rather than as a "tag". Therefore there is no tag FOO as a target<P>
|
|
of the <A REL=DEFINITION HREF="../Body/s_go.htm#go"><B>GO</B></A>.<P>
|
|
<P>
|
|
#2: (<A REL=DEFINITION HREF="../Body/s_symbol.htm#symbol-macrolet"><B>symbol-macrolet</B></A> ((foo (print 'loses)))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>let</B></A> ((<A REL=DEFINITION HREF="../Body/f_countc.htm#count"><B>count</B></A> 0))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>tagbody</B></A><P>
|
|
foo<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_when_.htm#when"><B>when</B></A> (< <A REL=DEFINITION HREF="../Body/f_countc.htm#count"><B>count</B></A> 5) (<A REL=DEFINITION HREF="../Body/m_incf_.htm#incf"><B>incf</B></A> <A REL=DEFINITION HREF="../Body/f_countc.htm#count"><B>count</B></A>) (<A REL=DEFINITION HREF="../Body/s_go.htm#go"><B>go</B></A> foo)))))<P>
|
|
<P>
|
|
This example returns <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> without printing anything, because FOO is<P>
|
|
treated as a "tag" rather than as a "statement".<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
This seems to be consistent with current practice.<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Lucid CL version 4.0, Allegro CL version 3.1, Chestnut's Lisp-to-C<P>
|
|
translator, and Symbolics Genera all signal an error for test case #1.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Small.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
Probably the only <A REL=DEFINITION HREF="../Body/t_class.htm#class"><B>class</B></A> of programs that would be affected are <P>
|
|
codewalkers. Codewalkers that produce code in which macro calls are <P>
|
|
replaced with macro expansions need to be careful that things that<P>
|
|
are initially parsed as <A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>tagbody</B></A> "statements" still appear to be <P>
|
|
"statements" in the output of the codewalker.<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
Unnecessary confusion in the language <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>. Implementations might<P>
|
|
differ for no good reason. Without an explicit clarification, people<P>
|
|
writing codewalkers might not realize that this is something they need<P>
|
|
to watch out for.<P>
|
|
<P>
|
|
<B>Performance impact:<P>
|
|
</B><P>
|
|
Probably none.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
The cost of non-adoption is avoided.<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
I think the alternatives are worse.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
This issue doesn't address the questions of whether duplicate tags are<P>
|
|
permitted or whether items that are not symbols, integers, or lists are<P>
|
|
permitted. It is probably acceptable to leave these unspecified in<P>
|
|
the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> on the assumption that syntax that isn't explicitly <P>
|
|
documented as being meaningful, isn't. <P>
|
|
<P>
|
|
Kent Pitman says:<P>
|
|
<P>
|
|
Ugh. Yes, please count me as a supporter of <A HREF="iss343.htm">TAGBODY-TAG-EXPANSION:NO</A>.<P>
|
|
<P>
|
|
Barry Margolin says:<P>
|
|
<P>
|
|
I've always been satisfied to treat this as implicitly vague, and I<P>
|
|
tell people to make sure their macros expand into a <A REL=DEFINITION HREF="../Body/s_progn.htm#progn"><B>PROGN</B></A> form if they<P>
|
|
want to be able to expand into an atom (e.g. expand into (<A REL=DEFINITION HREF="../Body/s_progn.htm#progn"><B>PROGN</B></A>)<P>
|
|
rather than <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> to do nothing).<P>
|
|
<P>
|
|
Loosemore notes:<P>
|
|
<P>
|
|
I think the idea of forcing *every* user-defined macro to deal with <P>
|
|
this lossage is pretty disgusting. The "right" place to deal with<P>
|
|
this is in the code-walkers that do the parsing of <A REL=DEFINITION HREF="../Body/s_tagbod.htm#tagbody"><B>TAGBODY</B></A> forms.<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>
|