Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] lazy vs function for values that are used once at most
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: henri dubois-ferriere <henridf@g...>
Subject: Re: [Caml-list] lazy vs function for values that are used once at most
ok.
actually, i should refine my question a little further:
in the vast majority of cases, the value is *not* used at all.
so i suppose the memoization overhead you mention does not occur when
a lazy value is not forced.

so, the question then becomes:

any difference in overhead between creating 
(lazy v)
and 
(fun () -> v)

?
thanks for any insights
henri







On Wed, 30 Jun 2004 14:39:15 +0100, Jon Harrop
<postmaster@jdh30.plus.com> wrote:
> 
> > when one has a value v that is going to be either used 0 or 1 time, is
> > there any difference in terms of overhead (ie for building the
> > closure,  GC performance, etc) between passing around  (lazy v) and
> > then forcing the value if needed, or passing around (fun () -> v) and
> > evaluating f when needed?
> 
> IIRC, Lazy is slower because of the (wasted, in this case) overhead of
> memoizing the result.
> 
> Cheers,
> Jon.
> 
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners