From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA24398; Wed, 30 Jun 2004 16:21:47 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA24391 for ; Wed, 30 Jun 2004 16:21:46 +0200 (MET DST) Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.249]) by concorde.inria.fr (8.12.10/8.12.10) with SMTP id i5UELiSH025758 for ; Wed, 30 Jun 2004 16:21:45 +0200 Received: by mproxy.gmail.com with SMTP id w29so1878621cwb for ; Wed, 30 Jun 2004 07:21:44 -0700 (PDT) Received: by 10.11.99.64 with SMTP id w64mr12196cwb; Wed, 30 Jun 2004 07:21:44 -0700 (PDT) Message-ID: Date: Wed, 30 Jun 2004 16:21:36 +0200 From: henri dubois-ferriere To: Jon Harrop Subject: Re: [Caml-list] lazy vs function for values that are used once at most Cc: Ocaml In-Reply-To: <200406301439.15289.postmaster@jdh30.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200406301439.15289.postmaster@jdh30.plus.com> X-Miltered: at concorde with ID 40E2CC78.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; henridf:01 caml-list:01 memoization:01 2004:99 postmaster:99 passing:01 passing:01 slower:01 memoizing:01 bug:01 faq:01 faq:01 beginner's:01 beginners:01 bin:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 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