[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue: LOAD-TIME-EVAL (Version 2)

The following from Jim Kempf:


	I've modified the proposal for LOAD-TIME-EVAL along the lines
suggested by Dave Moon and am resubmitting it. I'll keep the name of
the proposal at LOAD-TIME-EVAL, although LOAD-TIME-CONSTANT, as suggested
by Dave is probably a more appropriate name. SHARP-COMMA-SPECIAL-FORM
seems pretty much to be out, since the new proposal is for a functional
interface, rather than a special form.

	Note that Dave's proposal will require more extensive modifications
in our system than a macro or special form; however, I believe it is
more elegant, since it avoids introducing a new special form (one of
the original goals of Common Lisp), and therefore more appropriate.

			Jim Kempf	kempf@hplabs.hp.com


Issue:           LOAD-TIME-EVAL
References: #, (p. 356),  (EVAL-WHEN (LOAD) ...) (p. 69-70)
Category:     ADDITION
Edit history: Version 2 submitted 7/17/87, James Kempf.

Problem description:

The specification of #, (load time evaluation) in Common Lisp provides 
a means, during compilation, of arranging for the evaluation of a 
quoted or (in some implementations) unquoted form within embedded forms
processed by the reader, when the compiled file is loaded.
Inhibition of processing when a file is loaded into the interpreter
is possible using (EVAL-WHEN (LOAD) ... ). Code which is returned
during macroexpansion, however, is not processed by the reader, so
there is no way to arrange for deferral of processing until compiled
file load time in macroexpanded code.


(MAKE-LOAD-TIME-EVAL <quoted form> &ENVIRONMENT env) : function

When processed by the interpreter or when encountered during evaluation
of the COMPILE function, the <quoted form> is evaluated once (and only
once) and the result is returned. When processed during a file
compilation, arrangement is made for the <quoted form> to be
evaluated when the compiled file is loaded, and the result returned.
Note that determining when file compilation is occurring and the details
of arranging for deferral of further processing until compiled
file load time are necessarily implementation dependent.

Test Case: 

(defmacro print-load-date (&environment env)
  `(quote ,(make-load-time-eval '(format T "~A~%" (get-date) env))))

When interpreted or processed during invocation of COMPILE, this
macro expands into code which  prints the return value of the GET-DATE 
function (presumed, for purposes of this example, to be a human 
readable date) to *STANDARD-OUTPUT*. When macroexpanded during a
file compilation, printing is deferred until the compiled file is


Currently, there is no portable way to arrange for code returned
 from a macro to defer evaluation until load time.

Current practice:

Currently, every version of Common Lisp is required to implement
compiler hooks for #, but, since this is only recognized by
reader, there is no portable way to achieve the same effect. Users
of Portable CommonLoops are encouraged to implement something similar.

Adoption Cost: 

The cost to implementors will depend on how #, is implemented.
In some implementations, the primitives for implementing 
MAKE-LOAD-TIME-EVAL may already exist, in others, more substantial
changes may be required.

Cost of non-adoption: 

There are numerous possible uses for this facility. Version control
and system building facilities (such as the example) and optimization
of method invocation in the Common Lisp Object System come immediately
to mind. While every implementation of Common Lisp could certainly
provide an implementation specific facility, portability would suffer.


Portability. May make extensions to the Common Lisp Object system
via. the metaobject protocol easier.

Conversion Cost:

Most applications developers should not see much difference.


The proposal fills a hole in the spectrum of alternatives for deferring
evaluation until a compiled file is loaded. Currently, code which is 
read by the reader can arrange for it to be done, as can top level code,
but embedded code cannot.


There is likely to be some controversy about this proposal, since
there is no universally agreed upon formal processing model for
Common Lisp, but only a set of informal rules and various implementations.
Those implementations which have the primitives available should be
able to implement MAKE-LOAD-TIME-EVAL with little change to their
kernels, those which don't may require more extensive modifications.