[m-dev.] Re: for review: lazy evaluation [round 2]

Peter Schachte schachte at cs.mu.OZ.AU
Mon Mar 15 12:38:37 AEDT 1999


On Mon, Mar 15, 1999 at 01:16:51AM +0000, Lee Naish wrote:
> Fergus Henderson <fjh at cs.mu.OZ.AU> writes:

> >+:- 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.

Couldn't this be made prettier by instead declaring

	:- func append(lazy_list(T), lazy_list(T)) = lazy_list(T).

and then writing

append([], Ys) = Ys

?

> >+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?

Or "(func) = map(F, force_list(T))"

Better still, why can't "delay(map(F,force_list(T)))" work?

-- 
Peter Schachte                     We hang the petty thieves and appoint the
mailto:schachte at cs.mu.OZ.AU        great ones to public office.
http://www.cs.mu.oz.au/~schachte/      -- Aesop 
PGP: finger schachte at 128.250.37.3  



More information about the developers mailing list