Il giorno 25/mag/2015, alle ore 21.56, Matthias Felleisen ha scritto:
...
>> Yes, I was thinking about things like these in my other message. But
>> this alreaddy depends on the evaluation order which can be "reversed".
>> Right in this example one would like to mix in lazy evaluation.
>> 
>> (define the-view
>> {with-lazy-evaluation (new view% #model: (new model% #view: the-view)) })
> 
> There is a difference between lazy evaluation and cyclic references. 
> And it's huge. 
> 

In the specific example lazy evaluation would do the job, though.


> 
>> One might even think about an interpreter that automatically tries ...
> 
> See shared. That's NOT laziness. Repeat, it's NOT laziness. 
> 

Cyclic references or mutual hosting objects are not a problem at all.
It's only when you want the evualator handle that one line definition. But
a lazy evaluator solves this problem which a lot of people stumble over
as long as they have not yet adapted their way of thinking to the machine.


> 
> Here is what it takes (in principle) to extend it to objects: 
> 
> (define-syntax (object-shared stx)
> (syntax-case stx (new)
>   [(_ [(x x-field (new x% [x-field_ x0]))
>        (y y-field (new y% [y-field_ y0]))]
>       body)
>    #'(letrec ([x (new x% [x-field '*undefined-x*])]
>            [y (new y% [y-field y0])])
>        (set-field! x-field x x0)
>        #;
>        (set-field! y-field y y0)
>        body)]))
> 
> (define the-view
> (object-shared [(the-model view (new model% [view the-view]))
>                 (the-view model (new view% [model the-model]))]
>                the-view))
> 
> 

Sorry, ut I call it a workaround.

(define my-view (new view% #model: null))
(define my-model (new model% #view: null))
(send my-view set-model my-model)
(send my-model set-view my-view)

Every view should be able to handle a null or void model and every
model should be detachable from the view anyway.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to