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

Re: Replace LETREC with "relaxed" internal DEFINES.



I have several comments on the proposal to "RELAX THE LETREC RESTRICTION".

1.  The proposal as submitted and entered into the agenda has no bearing
on LETREC versus DEFINE.  Presumably anything done to relax the LETREC
restriction would relax the DEFINE restriction in exactly the same way,
since internal DEFINE is defined in terms of LETREC.

2.  The compiler cannot simply be expected to "find an order that works,
if any does", since that is not computable.  (Definitely not computable;
in an earlier message I wasn't sure.)

3.  It is therefore not enough to say that the compiler must find the
"best" order, since the obvious meaning of "best" is not computable and
it isn't clear what might be meant by the best computable order.

4.  To judge by a computer program submitted by John Ramsdell, the "best"
computable order is to be defined as follows: if an order that works can be
found by examining the static dependency graph of the LETREC variables and
the expressions giving their initial values (and by examining nothing else),
then the best order is any such order; otherwise the best order is arbitrary.
This does indeed relax the LETREC restriction found in R3RS.

5.  Apparently this proposal would require readers to construct and to sort
static dependency graphs topologically in order to understand LETREC and
internal definitions, when the writer of the code can easily make the
dependencies explicit by nesting the LETREC or internal definitions within
a LET*.  If the proposal ever affects the meaning of a program, therefore,
then either the writer of the program was deliberately being obscure or
else the writer has made a mistake.

6.  (Reductio ad absurdum.)  If this proposal is adopted, then it seems to
me that compilers should be required to choose an order of evaluation of
arguments that makes code like the following work:

   (let ()
     (define x)
     (define y)
     (define z)
     ((begin (set! z 3) +) (begin (set! y 2) x)
                           y
                           (begin (set! x 1) z)))

The computation that must be performed by the compiler or human reader
for this sort of code to be guaranteed to work is exactly the same as
the computation required by the proposed relaxation of the LETREC
restriction.

7.  (Disclaimer.)  I think it is wonderful that compilers compute
dependency graphs and topological sorts and so forth in order to
generate better code, but I think it is terrible when humans must
do the same.

Peace, Will