351 lines
24 KiB
HTML
351 lines
24 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 LOAD-TIME-EVAL 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/iss215_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss216_m.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss218_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/iss215_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss216_m.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss218_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue LOAD-TIME-EVAL Writeup</H2>
|
|
|
|
<PRE><B>Forum:</B> Compiler<P>
|
|
<B>Issue:</B> <A HREF="iss216_m.htm">LOAD-TIME-EVAL</A><P>
|
|
<B>References:</B> #, (p. 356), (<A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A> (<A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A>) ...) (p. 69-70)<P>
|
|
issue <A HREF="iss315.htm">SHARP-COMMA-CONFUSION</A><P>
|
|
<B>Category:</B> ADDITION<P>
|
|
<B>Edit history:</B> 06-Jun-87, Version 1 by James Kempf<P>
|
|
17-Jul-87, Version 2 by James Kempf<P>
|
|
12-Nov-87, Version 3 by Pitman (alternate direction)<P>
|
|
01-Feb-88, Version 4 by Moon<P>
|
|
(from version 2 w/ edits suggested by Masinter)<P>
|
|
06-Jun-88, Version 5 by Pitman<P>
|
|
(fairly major overhaul, merging versions 3 <A REL=DEFINITION HREF="../Body/a_and.htm#and"><B>and</B></A> 4)<P>
|
|
21-Sep-88, Version 6 by Moon (stripped down)<P>
|
|
17-Oct-88, Version 7 by Loosemore (change direction again)<P>
|
|
30-Dec-88, Version 8 by Loosemore (tweaks)<P>
|
|
23-Jan-89, Version 9 by Loosemore (amendments)<P>
|
|
02-Mar-89, Version 10 by Loosemore (new proposal)<P>
|
|
11-Mar-89, Version 11 by Loosemore<P>
|
|
<P>
|
|
<P>
|
|
<B>Problem description:<P>
|
|
</B><P>
|
|
Common Lisp provides reader syntax (#,) which allows the programmer<P>
|
|
to designate that a particular expression within a program is to be<P>
|
|
evaluated early (at load time) but to later be treated as a constant.<P>
|
|
Unfortunately, no access to this capability is available to programs<P>
|
|
which construct other programs without going through the reader.<P>
|
|
<P>
|
|
Some computations can be deferred until load time by use of <A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A>,<P>
|
|
but since <A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A> must occur only at toplevel, and since the nesting<P>
|
|
behavior of <A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A> is quite unintuitive, <A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A> is not a general<P>
|
|
solution to the problem of load-time computation of program constants.<P>
|
|
<P>
|
|
Proposal R**2-NEW-SPECIAL-FORM was approved at the January 1989<P>
|
|
meeting. After the meeting, some additional suggestions were made that<P>
|
|
have been incorporated into proposal R**3-NEW-SPECIAL-FORM. The sections<P>
|
|
of the two proposals that differ are marked with change bars in the margin.<P>
|
|
<P>
|
|
<B>Proposal (LOAD-TIME-EVAL:R**2-NEW-SPECIAL-FORM):<P>
|
|
</B> <P>
|
|
Add a new special form, <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A>, which has the following<P>
|
|
contract:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> form &optional read-only-p [Special Form]<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> provides a mechanism for delaying evaluation of <form><P>
|
|
until the expression is in the "runtime" environment. <P>
|
|
<P>
|
|
If a <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression is seen by <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>, the compiler<P>
|
|
| performs normal semantic processing such as macro expansion but<P>
|
|
| arranges for the evaluation of <form> to occur at load time in a null<P>
|
|
lexical environment, with the result of this evaluation then being<P>
|
|
treated as an immediate quantity at run time. It is guaranteed that <P>
|
|
the evaluation of <form> will take place only once when the file is <P>
|
|
loaded, but the order of evaluation with respect to the "evaluation" <P>
|
|
of top-level forms in the file is unspecified.<P>
|
|
<P>
|
|
If a <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression appears within a function compiled<P>
|
|
with <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A>, the <form> is evaluated at compile time in a null lexical<P>
|
|
environment. The result of this compile-time evaluation is treated as <P>
|
|
an immediate quantity in the compiled code. <P>
|
|
<P>
|
|
In interpreted code, <form> is evaluated (by <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A>) in a null<P>
|
|
lexical environment, and one value is returned. Implementations which<P>
|
|
implicitly compile (or partially compile) expressions passed to<P>
|
|
<A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> may evaluate the <form> only once, at the time this<P>
|
|
compilation is performed. This is intentionally similar to the<P>
|
|
freedom which implementations are given for the time of expanding<P>
|
|
macros in interpreted code.<P>
|
|
<P>
|
|
| Note that, in interpreted code, there is no guarantee as to when<P>
|
|
| evaluation of <form> will take place, or the number of times the<P>
|
|
| evaluation will be performed. Since successive evaluations of the<P>
|
|
| same <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression may or may not result in an evaluation<P>
|
|
| which returns a "fresh" object, destructive side-effects to the<P>
|
|
| resulting object may or may not persist from one evaluation to the<P>
|
|
| next. It is safest to explicitly initialize the object returned by<P>
|
|
| <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A>, if it is later modified destructively.<P>
|
|
| Implementations must guarantee that each reference to a<P>
|
|
| <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression results in at least one evaluation of its<P>
|
|
| nested <form>. For example,<P>
|
|
| (<A REL=DEFINITION HREF="../Body/m_defmac.htm#defmacro"><B>DEFMACRO</B></A> CONS-SELF (X)<P>
|
|
| `(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> ,X ,X))<P>
|
|
| (CONS-SELF (<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> (COMPUTE-IT)))<P>
|
|
| must perform two calls to COMPUTE-IT; although there is only one<P>
|
|
| unique <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression, there are two distinct references<P>
|
|
| to it.<P>
|
|
|<P>
|
|
| In the case of a <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> form appearing in a quoted expression <P>
|
|
| passed to <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A>, each call to <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> must result in a new evaluation of <P>
|
|
| <form>. For example,<P>
|
|
| (<A REL=DEFINITION HREF="../Body/m_defpar.htm#defvar"><B>DEFVAR</B></A> X 0)<P>
|
|
| (<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> FOO () (<A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> '(<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> (<A REL=DEFINITION HREF="../Body/m_incf_.htm#incf"><B>INCF</B></A> X))))<P>
|
|
| is guaranteed to increment X each time FOO is called, while<P>
|
|
| (<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> FOO () (<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> (<A REL=DEFINITION HREF="../Body/m_incf_.htm#incf"><B>INCF</B></A> X)))<P>
|
|
| may cause X to be evaluated only once.<P>
|
|
<P>
|
|
The READ-ONLY-P argument designates whether the result can be considered<P>
|
|
read-only constant. If <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> (the default), the result must be considered <P>
|
|
ordinary, modifiable data. If T, the result is a read-only quantity<P>
|
|
which may, as appropriate, be copied into read-only space and/or shared<P>
|
|
with other programs. (Because this is a special form, this argument is<P>
|
|
-not- evaluated and only the literal symbols T and <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> are permitted.)<P>
|
|
<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> is a special form rather than a function or macro <P>
|
|
because it requires special handling by the compiler.<P>
|
|
<P>
|
|
Requiring the compiler to perform semantic processing such as macro<P>
|
|
expansion on the nested <form>, rather than delaying all such processing<P>
|
|
until load time, has the advantages that fewer macro libraries may need<P>
|
|
to be available at load time, and that loading may be faster and result<P>
|
|
in less consing due to macroexpansion. If users really want to delay<P>
|
|
macroexpansion to load time, this can be done with an explicit call to<P>
|
|
<A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A>, e.g.<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> (<A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> '(MY-MACRO)))<P>
|
|
<P>
|
|
Allowing the same <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> to cause its nested <form> to be<P>
|
|
evaluated more than once makes simplifies its implementation in<P>
|
|
interpreters which do not perform a preprocessing code walk. It also<P>
|
|
makes the rules for the time of its processing analogous to those<P>
|
|
for macro expansion.<P>
|
|
<P>
|
|
This proposal explicitly does -not- tie <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> to the #,<P>
|
|
read macro. Doing so would be an incompatible change to the definition<P>
|
|
of #, (which is reliably useful only -inside- quoted <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A>,<P>
|
|
while <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> must appear -outside- quoted <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A> in a<P>
|
|
for-evaluation position).<P>
|
|
<P>
|
|
The requirement that <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expressions be evaluated once per<P>
|
|
reference (rather than once per unique expression) prevents problems <P>
|
|
that could result by performing destructive side-effects on a value <P>
|
|
that is unexpectedly referenced in more than one place.<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal (LOAD-TIME-EVAL:R**3-NEW-SPECIAL-FORM):<P>
|
|
</B> <P>
|
|
Add a new special form, <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A>, which has the following<P>
|
|
contract:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> form &optional read-only-p [Special Form]<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> provides a mechanism for delaying evaluation of <form><P>
|
|
until the expression is in the "runtime" environment. <P>
|
|
<P>
|
|
If a <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression is seen by <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>, the compiler<P>
|
|
| performs its normal semantic processing (such as macro expansion and<P>
|
|
| translation into machine code) on the form, but arranges for the<P>
|
|
| execution of <form> to occur at load time in a null<P>
|
|
lexical environment, with the result of this evaluation then being<P>
|
|
treated as an immediate quantity at run time. It is guaranteed that <P>
|
|
the evaluation of <form> will take place only once when the file is <P>
|
|
loaded, but the order of evaluation with respect to the "evaluation" <P>
|
|
of top-level forms in the file is unspecified.<P>
|
|
<P>
|
|
If a <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression appears within a function compiled<P>
|
|
with <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A>, the <form> is evaluated at compile time in a null lexical<P>
|
|
environment. The result of this compile-time evaluation is treated as <P>
|
|
an immediate quantity in the compiled code. <P>
|
|
<P>
|
|
In interpreted code, <form> is evaluated (by <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A>) in a null<P>
|
|
lexical environment, and one value is returned. Implementations which<P>
|
|
implicitly compile (or partially compile) expressions passed to<P>
|
|
<A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> may evaluate the <form> only once, at the time this<P>
|
|
compilation is performed. This is intentionally similar to the<P>
|
|
freedom which implementations are given for the time of expanding<P>
|
|
macros in interpreted code.<P>
|
|
<P>
|
|
| If the same (compared with <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A>) list (<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> <form>) is<P>
|
|
| evaluated or compiled more than once, it is unspecified whether <form><P>
|
|
| is evaluated only once or is evaluated more than once. This can<P>
|
|
| happen both when an expression being evaluated or compiled shares<P>
|
|
| substructure, and when the same expression is passed to <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> or to<P>
|
|
| <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> multiple times. Since a <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression may be<P>
|
|
| referenced in more than one place and may be evaluated multiple times<P>
|
|
| by the interpreter, it is unspecified whether each execution returns<P>
|
|
| a "fresh" object or returns the same object as some other execution.<P>
|
|
| Users must use caution when destructively modifying the resulting<P>
|
|
| object.<P>
|
|
|<P>
|
|
| If two lists (<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> <form>) are <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> but not <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A>, their<P>
|
|
| values always come from distinct evaluations of <form>. Coalescing<P>
|
|
| of these forms is not permitted.<P>
|
|
<P>
|
|
The READ-ONLY-P argument designates whether the result can be considered<P>
|
|
read-only constant. If <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> (the default), the result must be considered <P>
|
|
ordinary, modifiable data. If T, the result is a read-only quantity<P>
|
|
which may, as appropriate, be copied into read-only space and/or shared<P>
|
|
with other programs. (Because this is a special form, this argument is<P>
|
|
-not- evaluated and only the literal symbols T and <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> are permitted.)<P>
|
|
<P>
|
|
<P>
|
|
Rationale:<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> is a special form rather than a function or macro <P>
|
|
because it requires special handling by the compiler.<P>
|
|
<P>
|
|
Requiring the compiler to perform semantic processing such as macro<P>
|
|
expansion on the nested <form>, rather than delaying all such processing<P>
|
|
until load time, has the advantages that fewer macro libraries may need<P>
|
|
to be available at load time, and that loading may be faster and result<P>
|
|
in less consing due to macroexpansion. If users really want to delay<P>
|
|
macroexpansion to load time, this can be done with an explicit call to<P>
|
|
<A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A>, e.g.<P>
|
|
<P>
|
|
(<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> (<A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> '(MY-MACRO)))<P>
|
|
<P>
|
|
Allowing the same <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> to cause its nested <form> to be<P>
|
|
evaluated more than once makes simplifies its implementation in<P>
|
|
interpreters which do not perform a preprocessing code walk. It also<P>
|
|
makes the rules for the time of its processing analogous to those<P>
|
|
for macro expansion.<P>
|
|
<P>
|
|
This proposal explicitly does -not- tie <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> to the #,<P>
|
|
read macro. Doing so would be an incompatible change to the definition<P>
|
|
of #, (which is reliably useful only -inside- quoted <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A>,<P>
|
|
while <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> must appear -outside- quoted <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A> in a<P>
|
|
for-evaluation position).<P>
|
|
<P>
|
|
Allowing multiple references to the same <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expression<P>
|
|
to result in only one interpretation allows it to be specified more<P>
|
|
cleanly. It also allows interpreters that do not perform a prepass<P>
|
|
to cache <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> expressions.<P>
|
|
<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
This is an addition to the language and has not yet been implemented.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
In compiled code, (<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> <form>) is similar to <P>
|
|
'#,<form>. Most implementations can probably make use of the same <P>
|
|
mechanism they use to handle #, to handle <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A>. Note that<P>
|
|
#, does not currently <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> a mechanism for dealing with <P>
|
|
non-read-only-ness.<P>
|
|
<P>
|
|
Implementing <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> in the interpreter should be fairly<P>
|
|
straightforward, since one simply needs to evaluate the <form> in the<P>
|
|
null lexical environment. Implementations that use a preprocessing<P>
|
|
code walk in the interpreter to perform macro expansion could process<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> forms at that time.<P>
|
|
<P>
|
|
Some code-walkers would have to be taught about this new<P>
|
|
special form. Such changes would likely be trivial.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
Some code-walkers would have to be taught about this new<P>
|
|
special form. Such changes would likely be trivial.<P>
|
|
<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Users are given a mechanism that to force evaluation to be delayed <P>
|
|
until load time that does not rely on a feature of the reader.<P>
|
|
<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
Earlier versions (up to version 7) of this proposal stated that<P>
|
|
all semantic processing of the <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> form should be postponed<P>
|
|
until load time. <P>
|
|
<P>
|
|
The semantics of <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> would be simplified considerably if<P>
|
|
the READ-ONLY-P argument were removed and destructive operations on<P>
|
|
the result of evaluating <form> prohibited. However, some people feel<P>
|
|
that the ability to destructively modify the value is an essential<P>
|
|
feature to include.<P>
|
|
<P>
|
|
"Collapsing" of multiple references to the same <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> <P>
|
|
expression could be allowed for read-only situations, but it seems <P>
|
|
like it would be more confusing to make it legal in some situations <P>
|
|
and not in others.<P>
|
|
<P>
|
|
A number of other alternatives have been considered on this issue, <P>
|
|
including:<P>
|
|
<P>
|
|
- A proposal for a new special form that would force evaluation of<P>
|
|
the <form> to happen only once. This was rejected because of<P>
|
|
implementation difficulties.<P>
|
|
<P>
|
|
- A proposal to add a function making the "magic cookie" used by #,<P>
|
|
available to user code. The current proposal does not prevent such<P>
|
|
a function from being added, but this approach appeared to have<P>
|
|
less support than making the hook available as a new special form.<P>
|
|
<P>
|
|
- A proposal to remove #, entirely (issue <A HREF="iss315.htm">SHARP-COMMA-CONFUSION</A>).<P>
|
|
<P>
|
|
- A suggestion to change the behavior of (<A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A> (<A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A>) ...).<P>
|
|
<P>
|
|
<P>
|
|
Kent Pitman says:<P>
|
|
Although I'm willing to take multiple evaluation in the interpreter<P>
|
|
as a compromise position, I would like it mentioned in the discussion<P>
|
|
that this was only an expedient to getting this issue accepted at all,<P>
|
|
and that I'm not really happy about it. I have said that I think a<P>
|
|
number of our lingering problems (with <A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A>, COMPILER-LET, and<P>
|
|
this -- for example) are due to the presence of interpreters which do<P>
|
|
not do a semantic-prepass at a known time. If I had my way, we would<P>
|
|
<A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> a semantic pre-pass and we would then be able to forbid<P>
|
|
multiple evaluations even in the interpreter.<P>
|
|
<P>
|
|
Moon and Gray support proposal R**3-NEW-SPECIAL-FORM.<P>
|
|
<P>
|
|
Pitman also expressed willingness to go along with<P>
|
|
R**3-NEW-SPECIAL-FORM, but was somewhat concerned that coalescing<P>
|
|
<A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> results based on EQ-ness of the <A REL=DEFINITION HREF="../Body/s_ld_tim.htm#load-time-value"><B>LOAD-TIME-VALUE</B></A> form<P>
|
|
could conceivably lead to trouble down the line. However, since he<P>
|
|
could <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> no actual examples to back up that worry, and since the<P>
|
|
majority opinion was that some implementations would find a<P>
|
|
restriction against such coalescing an undue burden, the decision was<P>
|
|
made to just `note the concern' and proceed on. Sandra Loosemore and<P>
|
|
JonL White concur with this position.<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>
|