99 lines
5.2 KiB
HTML
99 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 DEFVAR-INIT-TIME 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/iss123_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss124.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss125_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/iss123_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss124.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss125_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue DEFVAR-INIT-TIME Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss124.htm">DEFVAR-INIT-TIME</A><P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> (p68)<P>
|
|
<B>Category:</B> CLARIFICATION<P>
|
|
<B>Edit history:</B> 23-Apr-87, Version 1 by Pitman<P>
|
|
29-Mar-87, Version 2 by Masinter<P>
|
|
<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
The description of <A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> is not completely clear about the time at<P>
|
|
which the initialization occurs.<P>
|
|
<P>
|
|
On p68 it says ``<A REL=DEFINITION HREF="../Body/f_docume.htm#variable"><B>VARIABLE</B></A> is initialized to the result of evaluating the<P>
|
|
form INITIAL-VALUE unless it already has a value. The INITIAL-VALUE form<P>
|
|
is not evaluated unless it is used; this fact is useful if evaluation of<P>
|
|
the INITIAL-VALUE form does something expensive like create a large data<P>
|
|
<A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A>.''<P>
|
|
<P>
|
|
At least one implementation interpreted the "unless it is used" to mean<P>
|
|
"unless the variable is used" rather than "unless the initial-value is<P>
|
|
to be used". The problem is that the "it" is ambiguous. Thus, <A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> was<P>
|
|
interpreted as a kind of lazy initialization that happened upon the<P>
|
|
variable's first unbound reference. (This interpretation appears to have<P>
|
|
been further supported by the additional wording in CLtL about not<P>
|
|
creating expensive structures that are not needed.)<P>
|
|
<P>
|
|
<B>Proposal (DEFVAR-INIT-TIME:NOT-DELAYED):<P>
|
|
</B><P>
|
|
Clarify that the evaluation of the initial value and the initialization<P>
|
|
happen at <A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> execution time (if at all). The cause of the confusion<P>
|
|
is the statement that the initial value form is not evaluated unless "it<P>
|
|
is used". Better to say that INITIAL-VALUE is evaluated if and only if<P>
|
|
the variable does not already have a value. Then there would be no<P>
|
|
confusion about the time of evaluation.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
This clarification follows the intent of the original Common Lisp<P>
|
|
designers.<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Nearly all implementations implement the proposed interpretation.<P>
|
|
<P>
|
|
<B>Adoption Cost:<P>
|
|
</B><P>
|
|
None, for most implementations; very small for any the implementation<P>
|
|
that adopted delayed evaluation.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
This clarification makes the semantics of an important primitive more<P>
|
|
well-defined.<P>
|
|
<P>
|
|
<B>Conversion Cost:<P>
|
|
</B><P>
|
|
Most users presumably expect the behavior currently in practice in most<P>
|
|
dialects. There's not a lot of code where the difference comes into play<P>
|
|
anyway. Presumably the conversion cost is fairly trivial.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
Being a clarification, this really doesn't have much aesthetic effect.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
The cleanup committee supports this clarification.<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>
|