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

Call-by-value (eager) vs. Call-by-name (lazy)



Although evaluation order was not the primary topic of the recent workshop
on Logic from Computer Science, I came away from the meeting with some 
questions about the relative merits of call-by-value and call-by-name. 
After stewing over this a bit,I thought it might be useful to raise the 
issue in this forum. 

One set of questions pertain to the practical tradeoff's between various
languages. For example, why is it that so many prefer call-by-value in
practice? The usual reason is "efficiency," but what does this mean?
More specifically, what level of implementation detail is required to
give a satisfactory account of the perceived efficiency of programming
using call-by-value. A complicating feature is that one wouldn't generally
write the same program in Scheme (or ML) as in Miranda (or Haskell).
So what can we say from a reasonably rigorous point of view?
Another aspect of this discussion is the presence of store-effecting operations.
Since evaluation order takes on a larger significance with assignment, say,
perhaps this is more of the reason to choose call-by-value languages in
practice. (Did anyone really like "Jensen's device" in Algol 60?)

A second set of questions have to do with programming language theory.
Given the predominance of call-by-value languages in practice, what is
the most appropriate theoretical approach? Does this necessarily imply
that we should drop cpo's with bottom in favor of Plotkin's domain theory?
("Pre-cpo's" was the term I think Abramsky suggested.) On the positive side,
in teaching, I find it much easier to explain the set-theoretic ordering 
on partial functions than the point-wise ordering on flat cpo's, for example.
Furthermore, at higher types, it is clear that the partial function approach
involves fewer artifical elements. On the other hand, I have found the
discussion of alternate reduction strategies very successful in my class,
with relationships to optimization, and I am somehow reluctant to drop
call-by-name. 
One technical point in this direction is that a non-strict 
conditional seems essential, and the pre-cpo interpretation of conditional
seems a bit contrived. But I am willing to be talked out of this.
Overall, I have a vague feeling that there may
be some additional "flexibility" in retaining bottom, and that it is
premature (at least given my limited understanding) to forget about it
altogether. Is this a reasonable intuition which needs technical justification,
or just an aversion to discarding something that took some effort to learn?

Comments?

John