From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id D219DBC88 for ; Tue, 8 Feb 2005 10:38:17 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j189cHX7020139 for ; Tue, 8 Feb 2005 10:38:17 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA13675 for ; Tue, 8 Feb 2005 10:38:16 +0100 (MET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j189cEmC020133 for ; Tue, 8 Feb 2005 10:38:16 +0100 Received: from [192.168.1.200] (ppp212-197.lns2.syd3.internode.on.net [203.122.212.197]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id j189bwYV037844; Tue, 8 Feb 2005 20:08:09 +1030 (CST) Subject: Re: [Caml-list] [Benchmark] NBody From: skaller Reply-To: skaller@users.sourceforge.net To: "Will M. Farr" Cc: "O'Caml Mailing List" , Christophe TROESTLER In-Reply-To: <80eb59bd970cd828d562f79e8eb565bf@mit.edu> References: <20050207.195724.87945401.Christophe.Troestler@umh.ac.be> <1107826151.13571.199.camel@pelican.wigram> <80eb59bd970cd828d562f79e8eb565bf@mit.edu> Content-Type: text/plain Message-Id: <1107855477.2555.95.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 08 Feb 2005 20:37:58 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 42088889.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42088887.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 mutable:01 arrays:01 mutable:01 arrays:01 ocaml:01 optimise:01 optimise:01 ocaml:01 glebe:01 48,:98 061:98 nsw:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: On Tue, 2005-02-08 at 12:48, Will M. Farr wrote: > Doesn't caml store records whose types are all floats as a float array > anyway? I thought I remembered this optimization going by in the > manual somewhere. But the types in your record are mutable, and so it can't possibly work. In particular, given two arrays of a record type R containing a mutable field M, the arrays MUST uses boxes or modifications to M in a shared record wouldn't be shared. OTOH if the field is not mutable there is no problem, but then you can't modify it, you can only use functional update on the record and store the whole thing back into the array. Perhaps Ocaml is actually smart enough to optimise type r = { m: float; n: float }; let x = Array.create 99 { m=0.0; n=0.0 } in x.[2] = { x.[2] with m = m + 1.0 }; so x is represnted by an array of float, and perhaps one could even optimise x.[2].m <- 22.0; even though it appears to be a type error (modifying an immutable field), it actually isn't, since you could always used functional update. However it isn't clear Ocaml type system uses the most expressive typing of 'constness', i.e. that it propages 'mutable' ness correctly. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net