[Haskell-cafe] strict, lazy, non-strict, eager
wren ng thornton
wren at freegeek.org
Mon Jan 9 10:53:52 CET 2012
On 12/28/11 10:23 AM, Jon Fairbairn wrote:
> Thiago Negri<evohunz at gmail.com> writes:
>
>> Lazy evaluation is one implementation of non-strict semantics, where
>> the arguments are evaluated only when they are needed.
>
> I would say this:
>
> * non-strict semantics require that no argument is evaluated
> unless needed.
I'm not sure that's quite right. As mentioned upthread, you can have
eager non-strict languages. I think the more correct way to view it is
that strict semantics require that non-termination of evaluating
arguments entails non-termination of evaluating the application ---i.e.,
if [[ x ]] == _|_ then [[ f x ]] == _|_---, whereas non-strict semantics
do not have this requirement.
Thus, we're allowed to evaluate unused arguments, provided that doing so
does not inhibit us from giving the proper result for evaluating the
application. Some possibilities would be: to fork off a thread for
evaluation of each subterm, or to eagerly evaluate arguments
optimistically but then fall back to a non-strict evaluation model if
the argument takes too long to finish, or to restrict ourselves to a
total language and then use any strict semantics we like (since strict
and non-strict coincide if there is no bottom),...
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list