[Haskell-beginners] Evaluation Order Semantics

Mike Meyer mike at fpcomplete.com
Tue Sep 24 22:10:54 CEST 2013


>
>
> Date: Tue, 24 Sep 2013 12:01:51 +0800
> From: ??? <wbbtiger at gmail.com>
>
> Yes, if the spec does not state the evaluation order I can't predict the
> performance definitely.
>

Well, depending on how definite you want to be, an inability to predict the
performance definitely is inherent in using compiled languages. That the
performance can change if you change the compilation options shows that. On
the other end of the scale, if you correctly implement an O(n) algorithm,
then it's definitely going to take at most O(n) steps to print the results
from it whether the language is strict or lazy.

Being more definite does get harder in the face of lazy evaluation, but it
also gets harder in the face of optimization. A lazy language will not
evaluate expressions whose value is never used. So will a good optimizing
compiler for a strict language.

Can you be a bit more explicit in what about performance you're trying to
predict?

Note to Keshav - yes, evaluating expressions you don't have to can change
the results. But I was talking about the evaluation order for expressions
you actually evaluate, though maybe I wasn't clear about it. Thanks for
pointing that out, though.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130924/4813db0c/attachment.htm>


More information about the Beginners mailing list