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 CAA19651; Wed, 13 Nov 2002 02:25:27 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 CAA19646 for ; Wed, 13 Nov 2002 02:25:26 +0100 (MET) Received: from favie.faith.gr.jp (favie.faith.gr.jp [61.127.175.250]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id gAD1PN111509 for ; Wed, 13 Nov 2002 02:25:24 +0100 (MET) Received: from localhost (dhcp7.faith.gr.jp [192.168.1.17]) by favie.faith.gr.jp (8.9.3/8.9.3) with ESMTP id KAA13890; Wed, 13 Nov 2002 10:12:04 +0900 To: rossberg@ps.uni-sb.de Cc: caml-list@inria.fr Subject: Re: [Caml-list] Records typing In-Reply-To: <3DCF97ED.6E81EB98@ps.uni-sb.de> References: <3DCF97ED.6E81EB98@ps.uni-sb.de> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20021113101131D.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 13 Nov 2002 10:11:31 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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. Jacques Garrigue ------------------- 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