From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 66B69D169 for ; Mon, 25 Jul 2005 01:23:21 +0200 (CEST) Received: from 26.mail-out.ovh.net (26.mail-out.ovh.net [213.186.42.179]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6ONNKil010842 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 25 Jul 2005 01:23:21 +0200 Received: (qmail 15339 invoked by uid 503); 24 Jul 2005 23:23:23 -0000 Received: (QMFILT: 1.0); 24 Jul 2005 23:23:23 -0000 Received: from b6.ovh.net (HELO mail47.ha.ovh.net) (213.186.33.56) by 26.mail-out.ovh.net with DES-CBC3-SHA encrypted SMTP; 24 Jul 2005 23:23:23 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 24 Jul 2005 23:23:21 -0000 Received: from mail47.ha.ovh.net (10.0.50.47) by mail47.ha.ovh.net with SMTP; 24 Jul 2005 23:23:18 -0000 Received: from b0.ovh.net (HELO queue-pre) (213.186.33.50) by b0.ovh.net with SMTP; 24 Jul 2005 23:23:18 -0000 Received: from adsl-69-229-239-54.dsl.scrm01.pacbell.net (HELO trantor.glondu.net) (postmaster%glondu.net@69.229.239.54) by ns0.ovh.net with SMTP; 24 Jul 2005 23:23:18 -0000 From: Stephane Glondu Organization: Crans To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] How to do this properly with OCaml? Date: Sun, 24 Jul 2005 16:23:12 -0700 User-Agent: KMail/1.7.1 Cc: skaller References: <200507241408.29014.Stephane.Glondu@crans.org> <1122242129.9027.229.camel@localhost.localdomain> In-Reply-To: <1122242129.9027.229.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200507241623.13705.Stephane.Glondu@crans.org> X-Ovh-Remote: 69.229.239.54 (adsl-69-229-239-54.dsl.scrm01.pacbell.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Miltered: at concorde with ID 42E422E9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocaml:01 initialise:01 initialise:01 non-empty:01 buffer:01 mutable:01 wrote:01 dependency:01 graph:01 define:01 define:01 inefficient:02 allocated:03 overhead:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Sunday 24 July 2005 14:55, skaller wrote: > If you have to initialise the store, it is expensive, I understand your point now. However, if you want your array to hold allocated values, you will always have to initialise the array. Moreover, I think the overhead of this initialisation is insignificant compared to the GC overhead. > and if you have to provide a dummy value it is hard > to use. Maybe hard is not the appropriate word. I would just say annoying. You can always define easily a dummy value when you define a (non-empty) type. One may argue that you may need to compute a path in a type dependency graph, but it is far-fetched: the path is given by the type definition! > then you can use the first value of the array as > the dummy value for the rest of the array, and avoid > Obj.magic -- however this is very inefficient, since > the dummy would have to be changed in many places > whenever the first entry in the array changed I didn't mean to change the dummy value all the time! Just take the first value as the dummy value, and keep it even if the first entry in the array changes. This will work fine for small values. If you are planning to put huge values in the array, I really think that the overhead of using an 'a option array is insignificant compared to the GC overhead. > (and that isn't just a store -- there is a write-barrier > to think about .. :) > > That won't happen in Buffer because you can't modify it, > but it must be allowed in more general variable length > mutable array. What do you mean? -- Stephane Glondu.