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 1E3DDBC88 for ; Tue, 8 Feb 2005 18:07:08 +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 j18H772r013792 for ; Tue, 8 Feb 2005 18:07:07 +0100 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 SAA31438 for ; Tue, 8 Feb 2005 18:07:07 +0100 (MET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j18H75gK014985 for ; Tue, 8 Feb 2005 18:07:06 +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 j18H6lYV062358; Wed, 9 Feb 2005 03:37:03 +1030 (CST) Subject: Re: [Caml-list] [Benchmark] NBody From: skaller Reply-To: skaller@users.sourceforge.net To: "Marcin 'Qrczak' Kowalczyk" Cc: caml-list In-Reply-To: <87zmyfjm0a.fsf@qrnik.zagroda> References: <20050207.195724.87945401.Christophe.Troestler@umh.ac.be> <1107826151.13571.199.camel@pelican.wigram> <80eb59bd970cd828d562f79e8eb565bf@mit.edu> <1107855477.2555.95.camel@pelican.wigram> <87zmyfjm0a.fsf@qrnik.zagroda> Content-Type: text/plain Message-Id: <1107882402.5022.171.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 09 Feb 2005 04:06:46 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4208F1BB.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4208F1B9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 sourceforge:01 mutable:01 mutable:01 unboxed:01 unboxing:01 ocaml:01 unboxed:01 const:01 ocaml:01 subtyping:01 'const':01 mistaken: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 23:04, Marcin 'Qrczak' Kowalczyk wrote: > skaller writes: > > > But the types in your record are mutable, and so it can't > > possibly work. > > It does work: mutable floats are unboxed too (if there are no > non-float fields). I'm talking about fully unboxing an array of records of floats into just an array of floats, and clearly that cannot be done if the record contains a mutable field, because if you assign the record to two different array elements, then modify the mutable field, both array elements would have to reflect the assignment. > > However it isn't clear Ocaml type system uses the most > > expressive typing of 'constness', i.e. that it propages > > 'mutable' ness correctly. > > There is nothing to propagate. There certainly is for unboxed data structures: if you store a record with an immutable field into a mutable field, the immutable field becomes mutable, because you can always use functional update. The mutability is thus mutable if the parent is mutable, whether or not the field is mutable. In other words mutability is inherited. In C++ this applies to lvalueness, but constness actually works in reverse: a non-const field is const if its parent is. For boxed fields, you may be right there is no propagation in Ocaml, but perhaps that indicates a lack of expressiveness, for example record subtyping is missing. In particular one can believe that a function accepting a record of immutable fields would not harm a record with the same structure but some mutable fields -- roughly the equivalent of C++ 'const' conversions. However unless I'm mistaken there is no way to do this, even though it appears sound and desirable. So saying 'there is nothing to propagate' isn't really meaningful, it seems circular: Ocaml doesn't propagate it therefore there isn't anything to propagate. Note I didn't claim there was a bug, I said merely that > it isn't clear Ocaml type system uses the most > > expressive typing of 'constness', -- 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