126 lines
7.1 KiB
HTML
126 lines
7.1 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 SETF-MACRO-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/iss306_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss307.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss308_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/iss306_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss307.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss308_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue SETF-MACRO-EXPANSION Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss307.htm">SETF-MACRO-EXPANSION</A><P>
|
|
<P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/m_defset.htm#defsetf"><B>DEFSETF</B></A>, DEFINE-SETF-METHOD, <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A><P>
|
|
CLtL pages 97, 102, 105<P>
|
|
ANSI CL spec 6-162 (Sep 89 version)<P>
|
|
<P>
|
|
Related issues: <A HREF="iss174.htm">FUNCTION-NAME:LARGE</A><P>
|
|
<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<P>
|
|
<B>Edit history:</B> 29-Apr-90, Version 1 by Moon<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B> <P>
|
|
CLtL is inconsistent because pages 102 and 105 say <A REL=DEFINITION HREF="../Body/m_defset.htm#defsetf"><B>DEFSETF</B></A> and<P>
|
|
DEFINE-SETF-METHOD can be used with a function or a macro, while page 97<P>
|
|
says that <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> expands macros before it looks for setf-methods.<P>
|
|
<P>
|
|
This is Symbolics issue #9.<P>
|
|
<P>
|
|
<B>Proposal (SETF-MACRO-EXPANSION:LAST):<P>
|
|
</B> <P>
|
|
Clarify that <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> (actually GET-SETF-METHOD-MULTIPLE-VALUE) only expands<P>
|
|
macros after exhausting all other possibilities other than expanding into<P>
|
|
a call to a function named (<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> reader). Clarify that it expands macros<P>
|
|
in the style of <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>MACROEXPAND-1</B></A> rather than <A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand"><B>MACROEXPAND</B></A> (this was point 11<P>
|
|
of <A HREF="iss174.htm">FUNCTION-NAME:LARGE</A> and is repeated here for clarity only).<P>
|
|
<P>
|
|
<B>Examples:<P>
|
|
</B><P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>defvar</B></A> *foo-trace* <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>nil</B></A>)<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>defmacro</B></A> foo (x y) `(<A REL=DEFINITION HREF="../Body/f_aref.htm#aref"><B>aref</B></A> ,x ,y))<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>defun</B></A> (<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> foo) (z x y) ;wrong<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_push.htm#push"><B>push</B></A> `(,x ,y ,z) *foo-trace*)<P>
|
|
(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> (<A REL=DEFINITION HREF="../Body/f_aref.htm#aref"><B>aref</B></A> x y) z))<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defset.htm#defsetf"><B>defsetf</B></A> foo (x y) (z) ;right<P>
|
|
`(<A REL=DEFINITION HREF="../Body/s_progn.htm#progn"><B>progn</B></A><P>
|
|
(<A REL=DEFINITION HREF="../Body/m_push.htm#push"><B>push</B></A> `(,,x ,,y ,,z) *foo-trace*)<P>
|
|
(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> (<A REL=DEFINITION HREF="../Body/f_aref.htm#aref"><B>aref</B></A> ,x ,y) ,z)))<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/f_mexp_.htm#macroexpand-1"><B>macroexpand-1</B></A> '(<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> (foo <A REL=DEFINITION HREF="../Body/t_array.htm#array"><B>array</B></A> i) (val)))<P>
|
|
<P>
|
|
The last form should include a push onto *foo-trace*, rather than<P>
|
|
first macroexpanding (foo array i) into (<A REL=DEFINITION HREF="../Body/f_aref.htm#aref"><B>aref</B></A> array i) and then<P>
|
|
<A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A>'ing that.<P>
|
|
<P>
|
|
The <A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>defun</B></A> form has no effect because <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> expands macros before expanding<P>
|
|
into a call to such a function, so this function will not be used.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
In the absence of this clarification, the language specification is not<P>
|
|
self-consistent. The example given above will not work in implementations<P>
|
|
that chose to believe CLtL page 97 rather than page 102.<P>
|
|
<P>
|
|
The rationale for <A HREF="iss174.htm">FUNCTION-NAME:LARGE</A> point 11 suggests that we thought<P>
|
|
we had exchanged the two bullets on page 97, so that <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>SETF</B></A> looks for <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A><P>
|
|
methods before it expands macros. However there doesn't seem to be any<P>
|
|
cleanup issue that explicitly addresses this.<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
Symbolics Genera looks for <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A> methods before expanding macros, I didn't<P>
|
|
check any other implementations.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Trivial.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
None.<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
The Common Lisp language will be a joke.<P>
|
|
<P>
|
|
<B>Performance impact:<P>
|
|
</B><P>
|
|
None.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Consistency.<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
Consistency.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
None.<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>
|