1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss228_w.htm

185 lines
12 KiB
HTML
Raw Normal View History

2024-04-01 10:24:07 +02:00
<!-- 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 MACRO-DECLARATIONS 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/iss227_w.htm">
<LINK REL=UP HREF="../Issues/iss228.htm">
<LINK REL=NEXT HREF="../Issues/iss229_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/iss227_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss228.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss229_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue MACRO-DECLARATIONS Writeup</H2>
<PRE><B>Forum:</B> Cleanup<P>
<B>Issue:</B> <A HREF="iss228.htm">MACRO-DECLARATIONS</A><P>
<B>References:</B> Issue <A HREF="iss337.htm">SYMBOL-MACROLET-DECLARE</A><P>
Issue <A HREF="iss092.htm">DECLARATION-SCOPE</A><P>
Issue <A HREF="iss096.htm">DECLARE-TYPE-FREE</A><P>
Issue <A REL=DEFINITION HREF="../Body/m_define.htm#define-compiler-macro"><B>DEFINE-COMPILER-MACRO</B></A><P>
Issue <A REL=DEFINITION HREF="../Body/d_dynami.htm#dynamic-extent"><B>DYNAMIC-EXTENT</B></A><P>
Issue <A HREF="iss141.htm">DYNAMIC-EXTENT-FUNCTION</A><P>
Declarations (CLtL chapter 9)<P>
<B>Category:</B> CLARIFICATION<P>
<B>Edit History:</B> V1, 26 Oct 1989, Sandra Loosemore<P>
V2, 02 Nov 1989, Sandra Loosemore (suggestions from Moon)<P>
<P>
<P>
<B>Problem Description:<P>
</B><P>
Issue <A HREF="iss337.htm">SYMBOL-MACROLET-DECLARE</A> defines a meaning for <A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> declarations<P>
when the lexically visible &quot;binding&quot; of the symbol names a<P>
symbol-macro. It also requires SYMBOL-MACRO to signal an error if a<P>
<A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> declaration is provided in the body for a symbol which it<P>
defines as a symbol-macro.<P>
<P>
What is the meaning of a <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> declaration appearing in some other<P>
context (such as in a <A REL=DEFINITION HREF="../Body/s_locall.htm#locally"><B>LOCALLY</B></A> construct), for a symbol for which the<P>
lexically apparent &quot;binding&quot; is a symbol-macro definition? How about<P>
any other declaration which normally applies to a variable or function<P>
binding (<A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A>, <A REL=DEFINITION HREF="../Body/d_dynami.htm#dynamic-extent"><B>DYNAMIC-EXTENT</B></A>, <A REL=DEFINITION HREF="../Body/d_ftype.htm#ftype"><B>FTYPE</B></A>, <A REL=DEFINITION HREF="../Body/d_inline.htm#inline"><B>INLINE</B></A>, <A REL=DEFINITION HREF="../Body/d_inline.htm#notinline"><B>NOTINLINE</B></A>) when the<P>
lexically apparent &quot;binding&quot; is a macro or symbol-macro definition? <P>
<P>
<P>
<B>Proposal (MACRO-DECLARATIONS:MAKE-EXPLICIT):<P>
</B><P>
Clarify that the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> declarations that apply to function or variable<P>
bindings have the following effects when the binding is a macro or<P>
symbol-macro:<P>
<P>
<A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A><P>
<A REL=DEFINITION HREF="../Body/s_symbol.htm#symbol-macrolet"><B>SYMBOL-MACROLET</B></A> signals an error if it includes a <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> declaration <P>
for any symbol that it binds as a symbol-macro. [Issue<P>
SYMBOL-MACROLET-DECLARE] Presumably, this error is of type <P>
<A REL=DEFINITION HREF="../Body/e_progra.htm#program-error"><B>PROGRAM-ERROR</B></A> and is signalled at compile-time rather than run-time.<P>
<P>
A <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> declaration for a symbol whose lexically visible binding<P>
is a symbol-macro causes that binding to be shadowed, in the same way<P>
that a <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> declaration shadows lexical variable bindings.<P>
<P>
<A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A><P>
A <A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> declaration for a symbol that names a symbol-macro is equivalent<P>
to wrapping a <A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A> expression around the expansion of that symbol-macro.<P>
[Issue SYMBOL-MACROLET-DECLARE] This is meaningful regardless of whether <P>
the declaration appears in the form that bound the symbol-macro or as a <P>
free declaration within the scope of the symbol-macro binding. Multiple<P>
<A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> declarations applying to a single symbol-macro binding are handled<P>
in the same way as multiple <A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> declarations that apply to a<P>
single variable binding.<P>
<P>
<A REL=DEFINITION HREF="../Body/d_ftype.htm#ftype"><B>FTYPE</B></A><P>
This declaration is not valid when the lexically apparent binding<P>
is a macro binding rather than a function binding. (This is because<P>
<A REL=DEFINITION HREF="../Body/d_ftype.htm#ftype"><B>FTYPE</B></A> declares the functional binding of the name to be of a particular<P>
subtype of <A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A>, and macros are not FUNCTIONs.)<P>
<P>
<A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A><P>
<A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A> declarations for symbol-macro bindings should be treated in <P>
exactly the same way as <A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A> declarations for variable bindings.<P>
In other words, such a declaration specifies that the bindings of<P>
of the specified symbol-macros are never used.<P>
<P>
<A REL=DEFINITION HREF="../Body/d_dynami.htm#dynamic-extent"><B>DYNAMIC-EXTENT</B></A><P>
This declaration is not valid when the lexically apparent binding<P>
is a symbol-macro or macro binding rather than a variable or<P>
function binding.<P>
<P>
<A REL=DEFINITION HREF="../Body/d_inline.htm#notinline"><B>NOTINLINE</B></A><P>
In the presence of <A REL=DEFINITION HREF="../Body/f_docume.htm#compiler-macro"><B>compiler-macro</B></A> definitions, this declaration<P>
affects references to macros in exactly the same way that it affects<P>
references to functions. When the lexically apparent binding is a <P>
macro that also has a <A REL=DEFINITION HREF="../Body/f_docume.htm#compiler-macro"><B>compiler-macro</B></A> definition, this declaration can <P>
be used to indicate to a language processor that the macro (and not the <P>
<A REL=DEFINITION HREF="../Body/f_docume.htm#compiler-macro"><B>compiler-macro</B></A>) definition should be used. [Issue <A REL=DEFINITION HREF="../Body/m_define.htm#define-compiler-macro"><B>DEFINE-COMPILER-MACRO</B></A>.]<P>
A <A REL=DEFINITION HREF="../Body/d_inline.htm#notinline"><B>NOTINLINE</B></A> declaration for a macro has otherwise has no effect on<P>
its expansion. Implementations are not free to ignore this declaration.<P>
<P>
<A REL=DEFINITION HREF="../Body/d_inline.htm#inline"><B>INLINE</B></A><P>
To parallel treatment of <A REL=DEFINITION HREF="../Body/d_inline.htm#notinline"><B>NOTINLINE</B></A>, in the presence of <A REL=DEFINITION HREF="../Body/f_docume.htm#compiler-macro"><B>compiler-macro</B></A><P>
definitions, this declaration affects references to macros in exactly<P>
the same way that it affects references to functions. When the lexically <P>
apparent binding is a macro that also has a <A REL=DEFINITION HREF="../Body/f_docume.htm#compiler-macro"><B>compiler-macro</B></A> definition, <P>
this declaration can be used to indicate to a language processor that <P>
the <A REL=DEFINITION HREF="../Body/f_docume.htm#compiler-macro"><B>compiler-macro</B></A> (and not the macro) definition should be used. An<P>
<A REL=DEFINITION HREF="../Body/d_inline.htm#inline"><B>INLINE</B></A> declaration for a macro otherwise has no effect on its expansion.<P>
Implementations are free to ignore this declaration.<P>
<P>
In those situations where the use of the declaration is not valid, the<P>
consequences of evaluating or compiling the program are undefined.<P>
<P>
<P>
<B>Rationale:<P>
</B><P>
This proposal is primarily an explicit restatement of things which have<P>
already been stated in other places, with some obvious interpolations<P>
added.<P>
<P>
Leaving the consequences undefined permits implementations to signal<P>
an error, to assign some implementation-specific interpretation to<P>
the declaration, or simply to ignore the declaration.<P>
<P>
<P>
<B>Current Practice:<P>
</B><P>
Utah Common Lisp implements this proposal. It currently ignores all<P>
declarations that apply to function or variable bindings when the<P>
lexically visible binding is a macro or symbol-macro. The<P>
declarations are added to the environment in the normal way but are<P>
never examined by the interpreter or compiler. The exception is that<P>
a <A REL=DEFINITION HREF="../Body/d_specia.htm#special"><B>SPECIAL</B></A> declaration will shadow a symbol-macro definition in the<P>
same way that it will shadow a lexical variable binding. <P>
<P>
Neither HPCL-I nor Lucid CL complain about <A REL=DEFINITION HREF="../Body/d_ftype.htm#ftype"><B>FTYPE</B></A> or INLINE/NOTINLINE<P>
declarations when the lexically visible function &quot;binding&quot; is a macro.<P>
They are apparently being ignored. KCL ignores all declarations<P>
that apply to function bindings (and doesn't yet support symbol-macros).<P>
<P>
<P>
<B>Cost to implementors:<P>
</B><P>
Presumably small. <P>
<P>
<P>
<B>Cost to users:<P>
</B><P>
It seems unlikely that this proposal would be an incompatible change<P>
that causes many user programs to break, particularly given the<P>
relative newness of symbol-macros and compiler-macros.<P>
<P>
<P>
<B>Benefits:<P>
</B><P>
More complete specification of the language and less chance for confusion<P>
to arise later on.<P>
<P>
<P>
<B>Aesthetics:<P>
</B><P>
Some people might be bothered by the asymmetry between the handling of<P>
<A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> and <A REL=DEFINITION HREF="../Body/d_ftype.htm#ftype"><B>FTYPE</B></A> declarations. Strictly speaking, the special handling for<P>
<A REL=DEFINITION HREF="../Body/a_type.htm#type"><B>TYPE</B></A> declarations is unnecessary since one could explicitly include the<P>
<A REL=DEFINITION HREF="../Body/s_the.htm#the"><B>THE</B></A> form in the expansion of the symbol-macro. Other people probably<P>
think that the notational convenience outweighs the asymmetry.<P>
<P>
<B>Discussion:<P>
</B>-------<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>