guile-user
[Top][All Lists]
Advanced

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

Re: lazy evaluation: Goops class/instance customization


From: Mikael Djurfeldt
Subject: Re: lazy evaluation: Goops class/instance customization
Date: Wed, 21 May 2003 11:07:09 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Maarten Grachten <address@hidden> writes:

> 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)))

Why are you using `primitive-eval'?

Shouldn't it be simply "(if (promise? v) (force v) v)"?

Best regards,
MD




reply via email to

[Prev in Thread] Current Thread [Next in Thread]