[plt-scheme] why local? (just curious)

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Thu Jan 15 13:27:30 EST 2009

> Now I've tried to think up an example myself in which both is present -
> as I can't get at anything sensible, I just put some sequential
> assignment in the beginning of the classic even-odd-letrec-example:
>
> (define test
>  (lambda (n)
>    (letrec ((start-value n)
>             (zero (- start-value start-value))
>             (even? (lambda (n) (if (= n zero) #t (odd? (- n 1)))))
>             (odd? (lambda (n) (if (= n zero) #f (even? (- n 1))))))
>      (odd? n))))
>
> (test 333)

The meaning of this program is undefined according to RnRS for n < 6.
Which means: In some implementations, it produces the answer you
expect.  In other implementations, it yields an error.  In still other
implementations, it might produce a different answer (or undefined, or
error) depending on the phase of the moon.

Shriram


Posted on the users mailing list.