[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Issue: LOAD-TIME-EVAL, SHARP-COMMA-SPECIAL-FORM (Version 1)
- To: firstname.lastname@example.org
- Subject: Re: Issue: LOAD-TIME-EVAL, SHARP-COMMA-SPECIAL-FORM (Version 1)
- From: Masinter.pa@Xerox.COM
- Date: 9 Jun 87 23:35 PDT
- Cc: kempf%hplabsc@hplabs.HP.COM
- In-reply-to: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>'s message of Tue, 9 Jun 87 23:14 EDT
David, I agree with most of your sentiments and encourage you to attempt
a revision. The issue currently has two names, neither of which are
particularly appropriate. One is LOAD-TIME-EVAL, and the other is
SHARP-COMMA-SPECIAL-FORM. Jim's message called it LOAD-TIME-EVAL. I
changed the proposal name to SHARP-COMMA-SPECIAL-FORM in the theory that
the *issue* was some programmatic way of getting at what sharp-comma did
(even if it isn't the same).
#, is one of the stickier bits of Common Lisp, since, like compiler-let
and a few others, it opens a distinction between compiled and
interpreted code that is otherwise outside the execution model. For that
reason, this seems like an issue we might have some difficulty with.
- - - - - - - - - - - - - - -
For general interest, I'll pass along the following: Interlisp has
something like this, in constant, deferredconstant and loadtimeconstant.
(constant x) can be implemented by
(defmacro constant (x) `',(eval x)).
E.g., (constant (char-code #\Space)). Some uses were for those places
where the compiler didn't know enough to do constant folding.
Occasionally it was used for things like (constant (get-date-string))
which would return the date the form was compiled, if at all. Of course,
the interpreted behavior is possibly erratic depending on the mechanism
for macro-expansion caching.
This is similar to constant, but the compiler recognized it specially,
and emitted a special coding so that the loader would evaluate x at load
time. Since it requires special processing by the loader to detect
(e.g., a special case in the fasl format) it is a "special form". I'm
not sure how one could implement this using only a function like
make-load-time-eval. (loadtimeconstant (get-date-string)) would return
the date the compiled code was loaded. Interpreted behavior is similar
to constant, i.e., evaluation time is not specified.
This gets evaluated on first reference. It can be implemented by
self-modifying code, e.g.,
(defmacro deferred-constant (x)
(let ((var (gentemp)))
(proclaim (list 'special var))
`(if (boundp ',var) ,var (setq ,var ,x))))
In Interlisp implementations that didn't provide load-time-constant, it
was permissible to emulate it using deferred-constant.