[Haskell-cafe] Re: Lazy evaluation from "Why Functional programming matters"

steffen steffen.siering at googlemail.com
Tue Oct 5 11:49:46 EDT 2010

Don't be to disappointed. One can always kinda fake lazy evaluation
using mutable cells.
But not that elegantly. In the example given above, all being used is
iterators as streams... this can also be expressed using lazy lists,
true. But one big difference between e.g. lazy lists and iterators is,
that lazy values are (operationally) replaced by their result wheres
values generated from iterators and streams are not.

For example one can use Iterators and chain them together in Java, to
achieve more or less the same space and runtime-efficiency found by
Stream-fusion in haskell (the Java JIT can abstract loads away, once
the iterators are build together). But If you need to access the
iterator's values more then once, you have to either force the full
iterator into a list or rerun/reevaluate the iterator every time you
need a value.

Lazy lists are nice, but haskell's laziness is not about lazy lists
only. For example lazy evaluation also matters when  creating
"elegant" Embedded DSLs... have you ever tried to build a more complex
EDSL without laziness and macros?

On 5 Okt., 16:52, C K Kashyap <ckkash... at gmail.com> wrote:
> > Yes. It would slightly easier in, say,  C# or C++.
> > I think 'D' achieves its implementation of the 'lazy' keyword using a
> > similar approach.
> > But I did not understand why you are disappointed ?
> The disappointment was not on a serious note ... the thing is, I
> constantly run into discussions
> about "why fp" with my colleagues - in a few of such discussions, I
> had mentioned that Haskell is the
> only well known language with lazy evaluation (IIRC, I read it
> somewhere or heard it in one of the videos)
> And I had built up this impression that laziness distinguished Haskell
> by a huge margin ... but it seems that is not the case.
> Hence the disappointment.
> --
> Regards,
> Kashyap
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-C... at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list