113 lines
5.2 KiB
HTML
113 lines
5.2 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 SELF-MODIFYING-CODE 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/iss300_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss301.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss302_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/iss300_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss301.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss302_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue SELF-MODIFYING-CODE Writeup</H2>
|
|
|
|
<PRE><B>Forum:</B> Public Review<P>
|
|
<B>Issue:</B> <A HREF="iss301.htm">SELF-MODIFYING-CODE</A><P>
|
|
<B>References:</B> Moon's public review comment #14 (X3J13/92-3214)<P>
|
|
Section 3.2.2.1.1 (purpose of compiler macros), p 3-17<P>
|
|
Section 3.1.2.1.2.2 (macro forms), p 3-7<P>
|
|
Issue <A REL=DEFINITION HREF="../Body/m_define.htm#define-compiler-macro"><B>DEFINE-COMPILER-MACRO</B></A><P>
|
|
Issue MACRO-CACHING<P>
|
|
<B>Category:</B> CLARIFICATION/CHANGE<P>
|
|
<B>Edit history:</B> 21 Dec 1992, Version 1 by Loosemore<P>
|
|
08 Jan 1993, Version 2 by Loosemore (comment from Moon)<P>
|
|
<B>Status:</B> Proposal FORBID accepted 7-2-0, March 1993<P>
|
|
<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
The last sentence of the second paragraph of section 3.2.2.1.1 on page<P>
|
|
3-17 says <A REL=DEFINITION HREF="../Body/f_docume.htm#compiler-macro"><B>compiler-macro</B></A> expanders aren't allowed to modify the source<P>
|
|
code. Is there a similar restriction on normal macro expanders? I<P>
|
|
expect that there would be, but I couldn't find it.<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal (SELF-MODIFYING-CODE:FORBID):<P>
|
|
</B><P>
|
|
Add to section 3.1.2.1.2.2 a statement that the consequences are <P>
|
|
undefined if a macro function destructively modifies any part of its<P>
|
|
form argument.<P>
|
|
<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
This would make the specification more complete.<P>
|
|
<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
Unknown.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to implementors:<P>
|
|
</B><P>
|
|
None.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to users:<P>
|
|
</B><P>
|
|
Conceivably this proposal might cause some existing conforming programs<P>
|
|
to become non-conforming, but we don't know of any such programs.<P>
|
|
<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
I think everybody agrees that writing self-modifying code is a<P>
|
|
bletcherous practice.<P>
|
|
<P>
|
|
<P>
|
|
<B>Editorial impact:<P>
|
|
</B><P>
|
|
Trivial.<P>
|
|
<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Loosemore says:<P>
|
|
The <A REL=DEFINITION HREF="../Body/m_define.htm#define-compiler-macro"><B>DEFINE-COMPILER-MACRO</B></A> proposal included the explicit prohibition<P>
|
|
against modification of the form argument because of the way a<P>
|
|
compiler macro function must return the original form to indicate it<P>
|
|
declines to expand it. Ordinary macros don't have to deal with this<P>
|
|
problem, but it's generally accepted that self-modifying macros are<P>
|
|
bad for other reasons. The problem description section of issue<P>
|
|
MACRO-CACHING, for example, touches upon this problem: "Caching by<P>
|
|
displacement won't work because the same (<A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A>) macro call form may<P>
|
|
appear in distinct lexical contexts. In addition, the macro call form<P>
|
|
may be a read-only constant."<P>
|
|
<P>
|
|
Moon says:<P>
|
|
I agree with <A HREF="iss301.htm">SELF-MODIFYING-CODE:FORBID</A> (Version 1).<P>
|
|
<P>
|
|
This is consistent with the chucking-out of displacing macros from<P>
|
|
Common Lisp.<P>
|
|
<P>
|
|
<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>
|