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

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



1.  To what extent is call-by-value vs. call-by-name the same question
as manual vs. automatic shift?  Efficiency and control seem to be
factors here.  With respect to the latter, with call-by-value the
programmer gets fine control over the timing of evaluation, by
judicious choice of quotes, i.e. levels of indirection.  With
call-by-name the system is expected to figure this out on its own.  The
predilection for call-by-value may simply reflect a lack of trust in
the ability of today's systems to do a good job of optimizing
call-by-name.

In between manual and automatic is a system that can think on its own
but that can also respond to advice from the programmer.  A dumb system
can always follow the advice literally.  A smarter system can ignore
the advice if it thinks it understands the situation better than the
programmer, whether by inspiration or by virtue of seeing things at
runtime that the programmer didn't know about when writing the code.
Best is when the interpreter and the programmer get to pool their
collective knowledge.  Do any of today's systems approach this?

Besides efficiency and control, there is also the question of
definition.  Are the meanings of call-by-value and call-by-name equally
clear?  Am I just imagining things, or is it really true that there are
more ways to screw up call-by-name than call-by-value?

2.  Arrays vs. functions.  Is there *any* situation where you would
want the default to be call-by-name when passing parameters to a
function but call-by-value (assign-by-value?) when storing into an
array, or vice versa?
-v