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 KAA29444; Wed, 13 Nov 2002 10:58:02 +0100 (MET) 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 KAA29449 for ; Wed, 13 Nov 2002 10:58:01 +0100 (MET) Received: from comtv.ru (comtv.ru [217.10.32.4]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gAD9w0X14813 for ; Wed, 13 Nov 2002 10:58:00 +0100 (MET) Received: from [10.0.66.9] ([10.0.66.9] verified) by comtv.ru (CommuniGate Pro SMTP 4.0) with ESMTP-TLS id 5472033; Wed, 13 Nov 2002 12:57:58 +0300 Date: Wed, 13 Nov 2002 12:55:03 +0300 (MSK) From: malc X-X-Sender: malc@home.oyster.ru To: Jacques Garrigue cc: rossberg@ps.uni-sb.de, Subject: Re: [Caml-list] Records typing In-Reply-To: <20021113101131D.garrigue@kurims.kyoto-u.ac.jp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, 13 Nov 2002, Jacques Garrigue wrote: First of all, thanks Andrea, Jacques. > From: Andreas Rossberg > > malc wrote: > > > > > > # module type T = sig type t type r = { f : t } end;; > > > module type T = sig type t and r = { f : t; } end > > > > > > # module M : T with type t = float = struct > > > type t = float > > > type r = { f : t } > > > end;; > > > > > > Signature mismatch: ... > > > > > > Is there a way to work around this? > > > > This seems to be a bug. You can work around it using "and" to connect > > the type declarations in the structure: > > > > # module type T = sig type t type r = { f : t } end;; > > module type T = sig type t and r = { f : t; } end > > # module M : T with type t = float = struct > > type t = float > > and r = { f : t } > > end;; > > module M : sig type t = float and r = { f : t; } end > > Actually this is not a bug. And your workaround is very interesting > (and useful). > The fact is, the two definitions are actually semantically different > (at least from the point of view of the compiler). > > % ocaml -dlambda > Objective Caml version 3.06+16 (2002-11-04) > > # module M = struct type t = float and r = {f:t} end;; > module M : sig type t = float and r = { f : t; } end > # {M.f = 1.0};; > [0: 1.0] > - : M.r = {M.f = 1.} > # module M' = struct type t = float type r = {f : t} end;; > module M' : sig type t = float and r = { f : t; } end > # {M'.f = 1.0};; > [|1.0|] > - : M'.r = {M'.f = 1.} > > In the first case, the record is represented as an array of a pointer > to a boxed float, while in the second case it is represented as an > array of an unboxed float. Since the data representation is different, > these two signatures are not equivalent. I was afraid there would be > no direct way to express the first case, but actually you can. What exactly triggered the switch from boxed to unboxed repersentation? I mean, this is completely unobvious and can have severe performance degradation, so description of cases when this might happen could be useful. -- mailto:malc@pulsesoft.com ------------------- 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