[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lazy evaluation: Goops class/instance customization
From: |
Maarten Grachten |
Subject: |
Re: lazy evaluation: Goops class/instance customization |
Date: |
Wed, 21 May 2003 10:14:09 +0200 (CEST) |
On Tue, 20 May 2003, Mikael Djurfeldt wrote:
> Please try to replace your version of compute-get-n-set with this:
> (An advantage of this code is that it will work for all kinds of
> slots, including instance slots and class slots.)
>
> (define-method (compute-get-n-set (class <Lazy-Eval-Metaclass>) slot)
> (let* ((g-n-s (next-method)) ;call "system" compute-get-n-set
> ;; now some "black magic"
> (getter (if (pair? g-n-s) (car g-n-s) (standard-get g-n-s)))
> (setter (if (pair? g-n-s) (cadr g-n-s) (standard-set g-n-s))))
> (list (lambda (o)
> (force (getter o)))
> setter)))
That worked! Although to meet my wishes, I changed the getter so
that it evaluates the the slot-value if it's a promise (and checks for a
promise before doing the force):
(define-method (compute-get-n-set (class <Lazy-Eval-Metaclass>) slot)
(let* ((g-n-s (next-method)) ;call "system" compute-get-n-set
;; now some "black magic"
(getter (if (pair? g-n-s) (car g-n-s) (standard-get g-n-s)))
(setter (if (pair? g-n-s) (cadr g-n-s) (standard-set g-n-s))))
(list (lambda (o)
(let ((v (getter o)))
(if (promise? v) (primitive-eval (force v)) v)))
setter)))
Thanks, very much!
Maarten
- lazy evaluation: Goops class/instance customization, Maarten Grachten, 2003/05/19
- Re: lazy evaluation: Goops class/instance customization, Mikael Djurfeldt, 2003/05/20
- Re: lazy evaluation: Goops class/instance customization,
Maarten Grachten <=
- Re: lazy evaluation: Goops class/instance customization, Mikael Djurfeldt, 2003/05/21
- Re: lazy evaluation: Goops class/instance customization, Maarten Grachten, 2003/05/21
- Re: lazy evaluation: Goops class/instance customization, Mikael Djurfeldt, 2003/05/21
- Re: lazy evaluation: Goops class/instance customization, Maarten Grachten, 2003/05/21
- Re: lazy evaluation: Goops class/instance customization, David Allouche, 2003/05/21
- Re: lazy evaluation: Goops class/instance customization, Mikael Djurfeldt, 2003/05/21
- Re: lazy evaluation: Goops class/instance customization, Maarten Grachten, 2003/05/22