[plt-scheme] semantics of letrec in Lazy Scheme

From: Keiko Nakata (keiko at kurims.kyoto-u.ac.jp)
Date: Tue Jun 2 09:21:28 EDT 2009

From: Eli Barzilay <eli at barzilay.org>
> On Jun  2, Keiko Nakata wrote:
> > In the following Lazy Scheme code, u is bound to #<undefiend>, 
> > whereas u1 and u2 are to promises producing 5. 
> > Why is u exceptional? 
> > 
> > #lang lazy
> > 
> > (define u (letrec ([x y] [y 5]) x))
> > [...]
> 
> That looks like a bug.  It's a result of an optimization --

It makes sense for me :)

I am also looking at another behavior which I do not understand:

> (define-values (v0 v1) (letrec ([x (begin (set! y 4) (print 0) 0)] [y (begin (print 1) 1)]) (values x y)))
> (force v0)
00
> (force v1)
11

But I could think this is also a side-effect of the same optimization.

Best,
Keiko


Posted on the users mailing list.