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

162 lines
8.7 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 SYMBOL-MACROLET-TYPE-DECLARATION 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/iss338_w.htm">
<LINK REL=UP HREF="../Issues/iss339.htm">
<LINK REL=NEXT HREF="../Issues/iss340_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/iss338_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss339.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss340_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue SYMBOL-MACROLET-TYPE-DECLARATION Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss339.htm">SYMBOL-MACROLET-TYPE-DECLARATION</A><P>
<B>References:</B> <A REL=DEFINITION HREF="../Body/s_symbol.htm#symbol-macrolet"><B>SYMBOL-MACROLET</B></A>, <A REL=DEFINITION HREF="../Body/s_declar.htm#declare"><B>DECLARE</B></A><P>
Related issues: <A HREF="iss337.htm">SYMBOL-MACROLET-DECLARE</A><P>
<A HREF="iss342.htm">SYNTACTIC-ENVIRONMENT-ACCESS</A><P>
<B>Category:</B> CLARIFICATON<P>
<B>Edit history:</B> v1, 13 Feb 1991, Sandra Loosemore<P>
v2, 11 Mar 1991, Sandra Loosemore (new proposal PROBABLY)<P>
<P>
<B>Problem description:<P>
</B><P>
Proposal <A HREF="iss337.htm">SYMBOL-MACROLET-DECLARE:ALLOW</A> says that a type declaration of<P>
a symbol defined as a symbol-macro &quot;is equivalent to wrapping a <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A><P>
expression around the expansion of that symbol&quot;. There is disagreement<P>
about whether &quot;equivalence&quot; was intended to mean &quot;semantic equivalence&quot;<P>
or &quot;literal equivalence&quot;. In other words, must (or might) the value <P>
returned by <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> or <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>MACROEXPAND-1</B></A> include a <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A> form if there<P>
are type declarations that apply to the symbol-macro being expanded?<P>
<P>
There are four proposals, YES, NO, MAYBE, and PROBABLY.<P>
<P>
<B>Proposal (SYMBOL-MACROLET-TYPE-DECLARATION:YES):<P>
</B><P>
Clarify that the equivalence is literal. If a type declaration<P>
is provided for a name that is bound as a symbol-macro, that type<P>
information must appear in the expansion of the symbol-macro <P>
returned by <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> or <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>MACROEXPAND-1</B></A> as a <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A> form wrapped around <P>
the expansion provided in its definition.<P>
<P>
Rationale for proposal YES:<P>
<P>
If the macroexpansion doesn't include the type information, it can<P>
be lost completely.<P>
<P>
<P>
<B>Proposal (SYMBOL-MACROLET-TYPE-DECLARATION:NO):<P>
</B><P>
Clarify that the equivalence is only in effect. The macroexpansion <P>
of a symbol-macro returned by <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> or <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>MACROEXPAND-1</B></A> is exactly<P>
the expansion provided in its definition.<P>
<P>
Rationale for proposal NO:<P>
<P>
As long as we permit implementations to discard declarations as a <P>
matter of policy, it's unreasonable type declarations on symbol<P>
macros to be collected.<P>
<P>
Type declarations about symbol-macros need not be lost during<P>
macroexpansion, since this information is returned by the<P>
VARIABLE-INFORMATION function. A code walker could wrap a <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A><P>
form around the expansion returned by <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>MACROEXPAND-1</B></A> itself, if<P>
it wished to do so.<P>
<P>
Maybe some programs depend on the expansion of a symbol-macro being<P>
exactly the same as what was specified in its definition.<P>
<P>
<P>
<B>Proposal (SYMBOL-MACROLET-TYPE-DECLARATION:MAYBE):<P>
</B><P>
Clarify that the equivalence may be either literal or only in effect.<P>
The macroexpansion of a symbol-macro returned by <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> or<P>
<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>MACROEXPAND-1</B></A> might or might not include a <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A> form wrapped around<P>
the the expansion provided in its definition.<P>
<P>
Rationale for proposal MAYBE:<P>
<P>
Some implementations might want to do things this way. Other<P>
implementations might not.<P>
<P>
<P>
<B>Proposal (SYMBOL-MACROLET-TYPE-DECLARATION:PROBABLY):<P>
</B><P>
Clarify that the equivalence is literal. If there is type information<P>
available in the environment in which the expansion occurs, then that<P>
type information must appear in the expansion of the symbol-macro <P>
returned by <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> or <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>MACROEXPAND-1</B></A> as a <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A> form wrapped around <P>
the expansion provided in its definition.<P>
<P>
Rationale for proposal PROBABLY:<P>
<P>
If the macroexpansion doesn't include the type information, it can<P>
be lost completely. However, this proposal makes no requirement that<P>
type declarations actually be collected (but it does imply that<P>
type declarations added by an explicit use of AUGMENT-ENVIRONMENT<P>
will be reflected in the expansions).<P>
<P>
<P>
<B>Current Practice:<P>
</B><P>
I don't know.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
In an implementation that discards type declarations, probably quite<P>
a bit of work would be involved to support proposal YES. However it<P>
may be that the implementors are doing this work anyway to support<P>
the other <A HREF="iss342.htm">syntactic-environment-access</A> proposals.<P>
<P>
<B>Cost to Users:<P>
</B><P>
Hard to say. Probably there are few programs that depend on any<P>
particular behavior here.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
Continuing confusion about how to write a code walker.<P>
<P>
<B>Performance impact:<P>
</B><P>
Most of the overhead is in keeping track of type declarations.<P>
<P>
<B>Benefits:<P>
</B><P>
The cost of non-adoption is avoided.<P>
<P>
<B>Esthetics:<P>
</B><P>
Seems to depend on who you talk to.<P>
<P>
<B>Discussion:<P>
</B><P>
Kim Barrett supports proposal PROBABLY.<P>
<P>
Kent Pitman says:<P>
...unless we're going to force declarations to be enforced, it <P>
isn't reasonable to make this requirement on macroexpansion.<P>
<P>
Loosemore supports proposal NO, not only because of this problem,<P>
but because it just seems unnecessarily complicated to force <P>
<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> to deal with declarations when there are other mechanisms <P>
for retrieving this information available to code walkers.<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>