[plt-scheme] semantics of letrec in Lazy Scheme

From: Jos Koot (jos.koot at telefonica.net)
Date: Tue Jun 2 09:05:52 EDT 2009

Eli Barzilay is the best man for your question, but looking into lazy, I see that in u the reference to y is not delayed. In u1 the 
expression for x is an application and is therefore treated lazily. What you see is not the value 5, but the printed datum 5. The 
value of u1 is void. In u2 the expression for x is a begin form, which is treated lazily too. For u2 both the printed datum and the 
value are 5. Now see:

#lang lazy
(define u3 (letrec ((x (~ y)) (y 5)) a))

In interactions window (! u3) --> 5

I think that in u the reference to y should be delayed implicitly, but may be there are reasons not to do so.
Jos

----- Original Message ----- 
From: "Keiko Nakata" <keiko at kurims.kyoto-u.ac.jp>
To: <plt-scheme at list.cs.brown.edu>
Sent: Tuesday, June 02, 2009 1:39 PM
Subject: [plt-scheme] semantics of letrec in Lazy Scheme


> Hello,
>
> 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))
> (define u1 (letrec ([x (print y)] [y 5]) x))
> (define u2 (letrec ([x (begin (print y) y)] [y 5]) x))
>
>
> Best,
> Keiko
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 



Posted on the users mailing list.