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: Maarten Grachten
Subject: Re: lazy evaluation: Goops class/instance customization
Date: Thu, 22 May 2003 11:25:44 +0200 (CEST)

On Wed, 21 May 2003, Mikael Djurfeldt wrote:

> Maarten Grachten <address@hidden> writes:
> 
> > On Wed, 21 May 2003, Mikael Djurfeldt wrote:
> >
> >> Then, in order to get correct semantics, you should remove
> >> `primitive-eval' and instead use the following (untested) version of
> >> make-lazy:
> >> 
> >> (defmacro make-lazy (specification . body)
> >>   (let ((attributes (map (lambda (x)      
> >>                            (if (keyword? x)
> >>                                x
> >>                                `(delay ,x)))
> >>                          body)))
> >>                 `(make ,specification
> >>                        ,@attributes)))
> >> 
> >
> > Ah. Indeed, that seems to work as well. But I don't really see where the 
> > crucial difference is. 
> > (not questioning the superiority of this solution :-)
> 
> Try the following code and compare the result for the old and the new
> make-lazy:
> 
> (define c ()
>   (x #:init-keyword #:x #:accessor x)
>   #:metaclass <Lazy-Eval-Metaclass>)
> 
> (define x 1147)
> 
> (define o
>         (let ((x 4711))
>           (make-lazy c #:x x))
> 
> (x o)
 
I see your point, when there is a bound variable at the time of using it 
in make-lazy, I want to have the value of that variable, instead of the 
value of the variable at the time of calling the getter. This is the 
difference isn't it?

Besides, I had to change the name of the x variable, because it shadowed 
the getter with the same name (such that (x o) raised a 'Wrong type to 
apply: 1147'). Is this something that can be avoided?





reply via email to

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