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

From: Jerzy Karczmarczuk (karczma at info.unicaen.fr)
Date: Mon Oct 28 02:27:49 EST 2002

Paul Steckler:

> Robert Bruce Findler:
> > In Scheme,...
> >   (letrec ([x <x-exp>]
> >            [y <y-exp>])
> >     <body-exp>)
> >
> > is the same thing as this:
> >
> >   (let ([x #<undefined>]
> >         [y #<undefined>])
> >     (set! x <x-exp>)
> >     (set! y <y-exp>)
> >     <body-exp>)
> 
> This is the translation suggested by RnRS.
> 
> > In the model (and in ML, on which the model is based), only "valuable"
> > expressions (ie, those beginning with "lambda" or those that are
> > constants) are allowed on the right-hand side of a definition, so you
> > don't need that more complex explanation of mututal recursion.
> 
> There was a paper in this year's Scheme Workshop, "Robust and effective
> transformation of letrec", by Waddell, Sarkar, and Dybvig, that takes
> this idea further, reorganizing letrec bindings according
> to the "valuable" criterion 

=====
Yeah.
And then a naive teacher of functional programming tells to his students
that in (letrec ([x <x-expr>]) something), x and <x-expr> belong to the
same environment, without further valuable explanations. And gets into the
black hole. Dear folks, I do not criticize the model nor its priests, but
for a Haskell sectarian this is a poison...

Guess what is (say, in DrScheme) the value of (cadr y) where
(define y
   (letrec ((x (cons 1 x)) x)
)

Yes, you guessed it right. Are you happy with it? I am not. But my
personal philosophy was rather coherent than valuable...

Jerzy Karczmarczuk


Posted on the users mailing list.