133 lines
8.4 KiB
HTML
133 lines
8.4 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 &ENVIRONMENT-BINDING-ORDER 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/I_Categ.htm">
|
|
<LINK REL=UP HREF="../Issues/iss001.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss002_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/I_Categ.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss001.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss002_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue &ENVIRONMENT-BINDING-ORDER Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> Proposal <A REL=DEFINITION HREF="../Body/f_firstc.htm#first"><B>FIRST</B></A> passed, Nov 89 X3J13<P>
|
|
<P>
|
|
<B>Forum:</B> Cleanup<P>
|
|
<B>Issue:</B> <A HREF="iss001.htm">&ENVIRONMENT-BINDING-ORDER</A><P>
|
|
<B>References:</B> CLtL p. 145-146, 63<P>
|
|
Issue <A HREF="iss106.htm">DEFMACRO-LAMBDA-LIST</A><P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit History:</B> V1, 24 Oct 1989, Sandra Loosemore<P>
|
|
V3, 02 Nov 1989, Sandra Loosemore (comments from Moon)<P>
|
|
<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
Issue <A HREF="iss106.htm">DEFMACRO-LAMBDA-LIST</A> states that <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> can appear once<P>
|
|
anywhere at top level of a macro <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list, but doesn't say anything<P>
|
|
about the order in which the <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> variable is bound relative<P>
|
|
to the other lambda-list variables.<P>
|
|
<P>
|
|
Some implementations treat <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> as a mechanism for naming the<P>
|
|
second argument to the macro function, in which case it is bound<P>
|
|
before any of the variables in the actual destructuring pattern.<P>
|
|
Other implementations bind it with the other <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> parameters in the<P>
|
|
usual left-to-right order.<P>
|
|
<P>
|
|
The binding order of <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> parameters is not an issue. This is<P>
|
|
because a <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> parameter must appear first in the <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list, so<P>
|
|
there is no difference between binding it first or binding it<P>
|
|
left-to-right. The relative binding order of <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> and <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A><P>
|
|
parameters is not an issue because neither one can include init forms<P>
|
|
where the binding of the other might be visible.<P>
|
|
<P>
|
|
There are two proposals, <A REL=DEFINITION HREF="../Body/f_firstc.htm#first"><B>FIRST</B></A> and LEFT-TO-RIGHT.<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal (&ENVIRONMENT-BINDING-ORDER:FIRST):<P>
|
|
</B><P>
|
|
Clarify that the <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> parameter is bound along with <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A><P>
|
|
before any of other variables in the <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list, regardless of where<P>
|
|
<A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> appears in the <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list.<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
This proposal provides a convenient explanation for the special<P>
|
|
treatment of <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> and <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> at top-level in a DEFMACRO-style<P>
|
|
<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list. Basically, these two parameters are stripped out and<P>
|
|
used to name the two arguments to the macro function, then the binding<P>
|
|
of the remaining arguments is handled exactly the same as at<P>
|
|
non-top-level or in a <A REL=DEFINITION HREF="../Body/m_destru.htm#destructuring-bind"><B>DESTRUCTURING-BIND</B></A>. It is also very<P>
|
|
straightforward to implement this model (as opposed to having<P>
|
|
special parsing code for destructuring top-level <A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A><P>
|
|
lists).<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal (&ENVIRONMENT-BINDING-ORDER:LEFT-TO-RIGHT):<P>
|
|
</B><P>
|
|
Clarify that the all <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> variables in a DEFMACRO-style <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> list<P>
|
|
are bound left-to-right, including the <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> and <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> parameters.<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
This is more consistent with the order in which variables in ordinary <P>
|
|
<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>lambda</B></A> lists are bound.<P>
|
|
<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Lucid CL, Utah CL, and KCL implement proposal <A REL=DEFINITION HREF="../Body/f_firstc.htm#first"><B>FIRST</B></A>. CMU CL<P>
|
|
implements proposal LEFT-TO-RIGHT.<P>
|
|
<P>
|
|
Symbolics Genera implements proposal <A REL=DEFINITION HREF="../Body/f_firstc.htm#first"><B>FIRST</B></A>. Specifically, <A REL=DEFINITION HREF="../Body/03_dd.htm#AMwhole"><B>&WHOLE</B></A> is<P>
|
|
bound first, followed by <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A>, then the destructuring<P>
|
|
variables in the order listed.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to implementors:<P>
|
|
</B><P>
|
|
The changes are probably localized but potentially hairy. It is<P>
|
|
possible that in some implementations it might be easier to completely<P>
|
|
replace the code which handles lambda-list parsing and destructuring<P>
|
|
than to try to patch it. Proposal <A REL=DEFINITION HREF="../Body/f_firstc.htm#first"><B>FIRST</B></A> is probably easier to<P>
|
|
implement initially but the cost of converting an existing<P>
|
|
implementation is probably about the same for both proposals.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to users:<P>
|
|
</B><P>
|
|
There are probably few user programs that would be affected by a<P>
|
|
change in the binding order of <A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&ENVIRONMENT</B></A> parameters.<P>
|
|
<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
The language specification is made more precise.<P>
|
|
<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Moon says:<P>
|
|
I believe LEFT-TO-RIGHT is more clean, but I don't have strong feelings.<P>
|
|
I am equally in favor of either of the two presented proposals or an<P>
|
|
EXPLICITLY-VAGUE proposal.<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>
|