|
From: Bruno H. <br...@cl...> - 2005-06-15 12:13:59
|
Don Cohen wrote:
> > If you want to avoid stupidly slow behaviour in the evaluator, i.e.
> > guarantee that a form is executed only once, you can use the MEMOIZED
> > macro, found in defs1.lisp.
>
> Is there any reason not to use this in the standard versions of
> defmacro and l-t-v ?
> If anyone really wants the uncached versions then they could be
> supplied via ext:...-uncached
About LOAD-TIME-VALUE: There are two reasons for keeping clisp's behaviour,
i.e. in the interpreter, reevaluate each time:
1) In the interpreter, the developer wants changes to other functions to
be activated immediately, without re-entering forms. Example:
;; Let's compute the volume of a ball with radius x.
(defun my-func (x) (* 4/3 pi (* x x)))
(defun my-func-normalized (x)
(/ (my-func x) (load-time-value (my-func 0.01))))
(my-func-normalized 1.0) => 10000
;; Oops, I made a mistake.
(defun my-func (x) (* 4/3 pi (* x x x)))
;; Try it again.
(my-func-normalized 1.0) => 1000000 ;; Good! - in CLISP
(my-func-normalized 1.0) => 10000 ;; Unexpected! - in SBCL
The point here is that the developer made a mistake in my-func,
so he corrects it, and expects things to work. He did not make
a mistake in my-func-normalized, so he does not want to reenter
this form.
This is where "early compile" can be encumbering.
2) MEMOIZED does extra consing; it's useless to do extra consing to
implement a behaviour of which ANSI CL says that you cannot count upon.
About DEFMACRO, it's not clear what you mean.
Bruno
|