129 lines
8 KiB
HTML
129 lines
8 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 FLET-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/iss158_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss159_m.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss161_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/iss158_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss159_m.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss161_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue FLET-DECLARATIONS Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss159_m.htm">FLET-DECLARATIONS</A><P>
|
|
<P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>FLET</B></A>, <A REL=DEFINITION HREF="../Body/s_flet_.htm#labels"><B>LABELS</B></A>, <A REL=DEFINITION HREF="../Body/s_flet_.htm#macrolet"><B>MACROLET</B></A> (CLtL p.113)<P>
|
|
X3J13 document 86-003 item 113<P>
|
|
Cleanup issue <A HREF="iss092.htm">DECLARATION-SCOPE</A>.<P>
|
|
Cleanup issue <A HREF="iss095.htm">DECLARE-MACROS</A>.<P>
|
|
<P>
|
|
<B>Category:</B> ADDITION<P>
|
|
<P>
|
|
<B>Edit history:</B> Version 1, Moon, 1 Jan 1988<P>
|
|
Version 2, Moon, 2 Feb 1988 (edits suggested by Masinter)<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
Declarations are not allowed before the body of <A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>FLET</B></A>, <A REL=DEFINITION HREF="../Body/s_flet_.htm#labels"><B>LABELS</B></A>, and<P>
|
|
<A REL=DEFINITION HREF="../Body/s_flet_.htm#macrolet"><B>MACROLET</B></A>, even though Common Lisp allows declarations in other seemingly<P>
|
|
analogous places, such as <A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A>.<P>
|
|
<P>
|
|
<B>Proposal (FLET-DECLARATIONS:ALLOW):<P>
|
|
</B><P>
|
|
Change the syntax of <A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>FLET</B></A>, <A REL=DEFINITION HREF="../Body/s_flet_.htm#labels"><B>LABELS</B></A>, and <A REL=DEFINITION HREF="../Body/s_flet_.htm#macrolet"><B>MACROLET</B></A> to allow declarations<P>
|
|
between the list of local function/macro definitions and the body forms.<P>
|
|
<P>
|
|
The scope of such declarations in <A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>FLET</B></A> and <A REL=DEFINITION HREF="../Body/s_flet_.htm#labels"><B>LABELS</B></A> includes the bodies<P>
|
|
of the locally defined functions, when the declarations are pervasive.<P>
|
|
Non-pervasive declarations have no effect on those bodies, except when<P>
|
|
<A REL=DEFINITION HREF="../Body/s_flet_.htm#labels"><B>LABELS</B></A> includes the body in the scope of a function non-pervasively<P>
|
|
declared. This paragraph follows directly from CLtL p.155 if the<P>
|
|
locally defined function bodies are treated like initialization forms.<P>
|
|
(This paragraph will be superseded by cleanup issue <A HREF="iss092.htm">DECLARATION-SCOPE</A><P>
|
|
<A REL=DEFINITION HREF="../Body/s_if.htm#if"><B>if</B></A> it passes.)<P>
|
|
<P>
|
|
The scope of such declarations does not include the bodies of the<P>
|
|
macro expander functions defined by <A REL=DEFINITION HREF="../Body/s_flet_.htm#macrolet"><B>MACROLET</B></A>. This is consistent with<P>
|
|
the existing rule that the bodies of those functions are in the global<P>
|
|
environment, not the local lexical environment.<P>
|
|
<P>
|
|
If cleanup issue <A HREF="iss095.htm">DECLARE-MACROS</A> is not passed, in <A REL=DEFINITION HREF="../Body/s_flet_.htm#macrolet"><B>MACROLET</B></A> an<P>
|
|
invocation of one of the macros locally defined by that <A REL=DEFINITION HREF="../Body/s_flet_.htm#macrolet"><B>MACROLET</B></A> is<P>
|
|
permitted to expand into a <A REL=DEFINITION HREF="../Body/s_declar.htm#declare"><B>DECLARE</B></A>.<P>
|
|
<P>
|
|
<B>Test Cases/Examples:<P>
|
|
</B><P>
|
|
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>defun</B></A> example (y l)<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>flet</B></A> ((attach (x)<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_setq.htm#setq"><B>setq</B></A> l (<A REL=DEFINITION HREF="../Body/f_append.htm#append"><B>append</B></A> l (<A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>list</B></A> x)))))<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_declar.htm#declare"><B>declare</B></A> (<A REL=DEFINITION HREF="../Body/d_inline.htm#inline"><B>inline</B></A> attach))<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_dolist.htm#dolist"><B>dolist</B></A> (x y)<P>
|
|
(<A REL=DEFINITION HREF="../Body/m_when_.htm#unless"><B>unless</B></A> (<A REL=DEFINITION HREF="../Body/a_null.htm#null"><B>null</B></A> (<A REL=DEFINITION HREF="../Body/f_car_c.htm#cdr"><B>cdr</B></A> x))<P>
|
|
(attach x)))<P>
|
|
l))<P>
|
|
<P>
|
|
(example '((a apple apricot) (b banana) (c cherry) (d) (e))<P>
|
|
'((1) (2) (3) (4 2) (5) (6 3 2)))<P>
|
|
=> ((1) (2) (3) (4 2) (5) (6 3 2) (a apple apricot) (b banana) (c cherry))<P>
|
|
<P>
|
|
The above function is erroneous in current Common Lisp. With this<P>
|
|
proposal, it would have an intuitively obvious meaning.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
This will make the syntax of <A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>FLET</B></A> and <A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> consistent. This will make<P>
|
|
it possible to attach declarations to function bindings; currently only<P>
|
|
variable bindings can have attached declarations.<P>
|
|
<P>
|
|
<B>Current practice:<P>
|
|
</B><P>
|
|
Xerox Common Lisp implements <A HREF="iss159_m.htm">FLET-DECLARATIONS:ALLOW</A>.<P>
|
|
Symbolics Common Lisp does not allow declarations in this position.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
The compilation and interpretation of three special forms will have to<P>
|
|
be changed, however the same techniques already developed for<P>
|
|
declarations in <A REL=DEFINITION HREF="../Body/s_let_l.htm#let"><B>LET</B></A> should be applicable.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
No cost since this is an upward-compatible addition.<P>
|
|
<P>
|
|
<B>Cost of non-adoption:<P>
|
|
</B><P>
|
|
Unnecessary inconsistency in the syntax of Common Lisp.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
There is no major benefit but the language will be more consistent.<P>
|
|
<P>
|
|
<B>Esthetics:<P>
|
|
</B><P>
|
|
Makes the language more consistent.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
We need to resolve this for CLOS, because CLOS introduces two new<P>
|
|
special forms similar to <A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>FLET</B></A> and <A REL=DEFINITION HREF="../Body/s_flet_.htm#labels"><B>LABELS</B></A> and we need to make their<P>
|
|
syntax consistent with <A REL=DEFINITION HREF="../Body/s_flet_.htm#flet"><B>FLET</B></A> and <A REL=DEFINITION HREF="../Body/s_flet_.htm#labels"><B>LABELS</B></A>.<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>
|