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: Jon Harrop <postmaster@j...>
Subject: Re: [Caml-list] lazy vs function for values that are used once at most

> 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