[Haskell-cafe] Re: Haskell vs OCaml

ajb at spamcop.net ajb at spamcop.net
Wed May 4 03:02:58 EDT 2005


G'day all.

On Tue, 3 May 2005 21:04:46 -0700
Andrew Pimlott <andrew at pimlott.net> wrote:

> > The advantage of lazy evaluation is that evaluation order becomes one
> > less thing you have to think about.

Quoting Erik de Castro Lopo <hc-erikd at mega-nerd.com>:

> Yes, but only if your functions are pure.

Right.

> >  The disadvantage of lazy evaluation
> > is that evaluation order becomes one more thing you have to think about.
>
> Yes, but only if your functions are impure.

Wrong.  An unevaluated thunk can, in general, be much larger than what
the thunk evaluates to.  (Think of "length" of a large list, for example.)
If such a thunk is unevaluated but not garbage for a considerable time,
then you have a space leak.

So you do need to think about evaluation order.  One good rule of thumb
is: On large data structures, try to have a single consumer only.

Cheers,
Andrew Bromage


More information about the Haskell-Cafe mailing list