[plt-scheme] Letrect (was blah. units)

From: Jerzy Karczmarczuk (karczma at info.unicaen.fr)
Date: Thu Oct 31 05:08:43 EST 2002

Zbyszek Jurkiewicz says that in my example, (cadr y), where:

>>(define y
>>   (letrec ((x (cons 1 x))) x)

>...you get what you pay for.  Scheme is not lazy, so there 
> is no appropriate behaviour here.  One cannot signal unbound
> variable error here, because x is bound.  There is some
> discussion of this in SICP in connection with internal DEFINEs.

> If you introduce laziness here, you would get problems with 
> assignments (or its newer verision known as object-oriented
> programming).

I am sorry, but this has no compulsory relation to laziness. If
in one place you say explicitly that in letrec the definiens and
the definiendum belong to the same environment, and then you admit
that the only place where this work is where definiens is "lazy"
in the sense that it postpones the evaluation (lambda form contains
only the reference to the possible bindings of "x"), then you
might sleep well, but you make such perverts as myself unhappy.

A cyclic list is not a lazy construct. You might implement it
differently: binding "x" to <undefined> if you wish, reassign it,
but then replace all the internal occurrences of x in the data
structure with the assigned value. An intelligent SECD compiler
may do that.

I do not claim that it would be a Good Thing, but, please, dont
tell me that it breaks any rules of "classical" strict programming.

Jerzy Karczmarczuk

Posted on the users mailing list.