[plt-scheme] Re: to define, or to let

From: Bill Richter (richter at math.northwestern.edu)
Date: Thu Apr 8 23:39:36 EDT 2004

    Anton van Straaten <anton at appsolutions.com> wrote:

   Most Scheme implementations ignore [R5RS], and implement letrec as
   though it were letrec*.  Letrec-as-letrec* allows its initializers
   to refer, at the time they are first evaluated, to variables bound
   earlier ("to the left") in the same letrec.  This inherently
   guarantees a left-to-right order of evaluation.  By contrast, R5RS
   letrec doesn't allow initializer evaluation to refer to variables
   bound in the same letrec, and also doesn't guarantee an evaluation
   order.

I get it: letrec* is like let*, which I use all the time, I rarely use
let, because as you say, let* is a "binding+sequencing construct."  So
I guess I'm with vast majority, and prefer letrec* to the R5RS letrec.
But R5RS letrec doesn't sound busted to me, and I think you agree.

   An implementation of R5RS letrec is semantically safe, by Matthias'
   criterion, if it provides a fixed order of evaluation for the
   initializers.

That's what I'm missing, Anton.  Did I miss a long discussion?  I like
left-to-right eval, but why is a fixed order of evaluation safer?
Maybe it's safer to be forced to code so that order of evaluation
doesn't matter.  Taking this to the extreme, we get functional
programming, which everyone likes!  What's this semantic ambiguity:

   letrec [with guaranteed left-to-right evaluation order for its
   initializers] with does not suffer from the semantic ambiguity
   which Matthias is concerned with.


Posted on the users mailing list.