[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: expansion of LETREC (hmmm)

I have had two people express great surprise and chagrin that
LETREC does not guarantee left-to-right evaluation as does LET*.
(One is a veteran in computer science; the other is an economist
with substantial programming experience in a few unmentionable
languages.  Both were new to Scheme.) They both wanted to use LET
when there is no constraint on ordering, LET* when the ordering
is sequential, and LETREC when there is recursion or circularity.
Both felt that they should be able to use LETREC wherever they
could have used LET*, (unless they needed to use a variable with
a conflicting name outside of the form).  In other words, they
felt that LET, LET* and LETREC formed (or should form) a linear
sequence, each more powerful (in a sense) than the last.  They
felt that the restrictions on LETREC were arbitrary and useless.

When I showed them the definitions of LET, LET* and LETREC (the
latter in terms of let and set!), both pointed out that it would
be trivial to support this functionality.  In other words, they
wanted the definition for LETREC given in my last note:

   (letrec ((x v) ...) e ...)
       (let ((x 'any) ...) (set! x v) ... e ...)

This issue, of course, does not concern those who avoid anything
but lambda expressions in LETREC.

I'm not sure I see any harm in this definition of LETREC, but I
haven't come to any real conclusion on this matter.  It certainly
has the merits of reducing confusion and making the writing of the
RRRS easier.