Re: method combinations



On Mon, 17 Jul 2006 19:01:49 -0700, Ari Krupnik <ari@xxxxxxxx> wrote:

(defclass dynamic ()
(slot-a :reader a)
(slot-b :reader b)

(defmethod c ((dy dynamic))
;expensive computations
)

(defmethod d ((dy dynamic))
;expensive computations
)

(defclass precomputed (dynamic)
(slot-c :reader c)
(slot-d :reader d))

(defmethod initialize-instance :after ((pc precomputed) &key c d)
(with-slots (slot-c slot-d) pc
(setf slot-c (c p)) ; tautology
(setf slot-d (d p))))

Ari, I would suggest getting rid of the readers for slot-c and
slot-d. In the c and d methods specialized on precomputed,
call-next-method if necessary to store the result in the
appropriate slot, then return the cached value.

--
Jack Unrue
.



Relevant Pages

  • method combinations
    ... I want to inherit from this class to include slots that can ... to a reader method. ... (with-slots (slot-c slot-d) ...
    (comp.lang.lisp)
  • Re: method combinations
    ... (slot-a:reader a) ... (with-slots (slot-c slot-d) ...
    (comp.lang.lisp)