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


I wrote:

>    I don't know what other people had in mind, but in other situations it's often
>    a good idea to put the function last, because it is textually large.  This
>    makes the program easier to read.  (ie, it makes the program mentally
>    tail-recursive).  Thus 

and rpg replied:

> This is what LET is for (among other things), no? Hard to make a
> cogent case that APPLY and CALL-WITH-VALUES are each right in their
> argument order yet different from each other.

No, the case is simple: likely longest argument goes last.  If you don't
believe me, try writing some cps code in which the continuation argument goes
first, eg (define fib (lambda (k n)...)) .  In fact, lots of times it would be
nice to have a WHERE construct, which would be just like LET, except the
declarations textually follow the body.

The notion of sequencing also distinguishes the two cases.  CALL-WITH-VALUES
is most likely (though not always!) going to be in tail position (in some
context), so there's real sequencing going on, and the receiver is the part
that's executed last.  [insert discussion of monads here:-]  The same case
cannot be made for APPLY, which is just a repackaging of the elements of an
ordinary procedure call.  This is unlikely to be in tail position (though it
might be), so one generally wants to think of it as a function, not a
sequencing operation. [insert text of "Lambda: The Ultimate Goto" here:-].

Perhaps someone who was at the meeting can answer Christian's original
question, which was more like "what were you guys thinking of, anyway?"  I
wasn't there, so I can't answer THAT question.