for review: lazy evaluation [round 2]

Lee Naish lee at cs.mu.OZ.AU
Mon Mar 15 12:16:51 AEDT 1999


Fergus Henderson <fjh at cs.mu.OZ.AU> writes:

I think the additional comments + examples help a lot.

>+% some implementation details of the Mercury implementation.

See previous review (Peter's?).

>+:- func append(lazy_list(T), lazy(lazy_list(T))) = lazy_list(T).

>+append([], Ys) = force_list(Ys).

This is an example where the naive "append([], Ys) = Ys" doesn't work
because the lazy wrapper is not integrated into the list type.

>+member(X, [_ | Xs]) :-
>+	member(X, force_list(Xs)).

This is a different case of the same kind of thing.  Doesn't look too
bad though.

>+map(F, [H|T]) = [F(H) | delay((func) = R :- R = map(F, force_list(T)))].
                                ^^^^^^^^^^^^^^^^^^
I wonder if this can be made less ugly.  Its tempting to encapsulate it
in some way but it probably needs a call by name construct which might
be even worse than messy syntax.  Or could you get away with
"func map(F, force_list(T))" denoting the closure?

	lee



More information about the developers mailing list