Thoughts on laziness (long)

Robert Virding rv@REDACTED
Wed Oct 18 13:11:44 CEST 2000


Jeffrey Straszhiem <stimuli@REDACTED> writes:
>Hi,
... Long discussion on call by need laziness
>

I personally think that laziness can be interesting but have yet come 
across any applications in Erlang where it would have been useful.

Many of the uses of laziness in other functional languages are handled
in Erlang with processes and message communication.  Implementing lazy 
streams for communication does not give you very much and in many cases 
is much more limiting than Erlang's message passing with selective 
receives.

Another problem with call-by-need, which I tried to point out in an
earlier mail, is that it creates problems when used in conjunction with
processes and distribution.  For many applicattions it IS important WHEN
and WHERE things are done.

You also have the proble that in Erlang programs there are many 
functiona calls which are done for effect, send a message, so waiting 
to evaluate them until you need the result won't give you much. :-)

My solution was, as mentioned, force full evalutaion for all messages 
and for all calls which ignore the result.  This should make the most 
things work, but you will still end up with sequencing problems:

    R1 = foo(...),
    R2 = bar(...),

If R1 and R2 are used then both foo nad bar will be called but I may 
lose control of the order, which may be important.

This is similar to the problems we had when implementing Erlang on top 
of Strand, a parallel logic language, where I had to pass around a 
state variable and wait for it everywhere just to be sure of sequencing.

I agree, however, that to make this work properly it would have to be 
proper call-by-need with updating of the heap when a result has been 
evaluated.

However, I wonder if it possible to update Erlang with such a feature 
and still keep it sufficiently backwards compatible to call be able to 
call it the same language.  You might end up with a new language, Lazy 
Erlang, with new semantics.

	Robert

-- 
Robert Virding                          Tel: +46 (0)8 545 55 017
Alteon Web Systems                      Email: rv@REDACTED
S:t Eriksgatan 44                       WWW: http://www.bluetail.com/~rv
SE-112 34 Stockholm, SWEDEN
"Folk säger att jag inte bryr mig om någonting, men det skiter jag i".





More information about the erlang-questions mailing list