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 OAA17845; Thu, 22 Mar 2001 14:10:21 +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 OAA17638 for ; Thu, 22 Mar 2001 14:10:20 +0100 (MET) Received: from dpt-info.u-strasbg.fr (dpt-info.u-strasbg.fr [130.79.6.1]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f2MDAJT08308 for ; Thu, 22 Mar 2001 14:10:19 +0100 (MET) Received: from lambda.u-strasbg.fr (lambda.u-strasbg.fr [130.79.90.63]) by dpt-info.u-strasbg.fr (8.9.3/8.9.3) with ESMTP id OAA00325; Thu, 22 Mar 2001 14:09:58 +0100 Received: from luther by lambda.u-strasbg.fr with local (Exim 3.22 #1 (Debian)) id 14g4r4-0007UR-00; Thu, 22 Mar 2001 14:10:18 +0100 Date: Thu, 22 Mar 2001 14:10:18 +0100 To: Alex Baretta Cc: "caml-list@inria.fr" Subject: Re: [Caml-list] Records Message-ID: <20010322141018.A27738@lambda.u-strasbg.fr> References: <3AB9F13C.1B77C08@baretta.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: <3AB9F13C.1B77C08@baretta.com>; from alex@baretta.com on Thu, Mar 22, 2001 at 01:34:04PM +0100 From: Sven LUTHER Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Mar 22, 2001 at 01:34:04PM +0100, Alex Baretta wrote: > Basically I'm trying to define two record type as sharing some > field names. I have tried twice, apparently in the same way, and > obtained two different error messages, which seem to contradict > one another. Could anyone explain to me what is happening here? > > > Objective Caml version 3.00 > > # type rec1 = { field1 : int } > type rec2 = { field1 : int ; field2 : int };; <--- Here I define > my two record types > type rec1 = { field1 : int; } > type rec2 = { field1 : int; field2 : int; } > # { field1 = 1 };; <--- This is supposed to be a correct rec1 no, it is a rec2 record, since field1 was lastly defined for rec2. One workaround would be : module Rec1 = struct type t = {field1 : int} end module Rec2 = struct type t = { field1 : int; field2 : int; } end Then you can do : {Rec1.field1 = 1} : Rec1.t or {Rec2.field1 = 1; Rec2.field2 = 2} : Rec2.t If you are interrestedin more such things, i remember a discution about such things some time ago on this list, please look at the mailing list archive for more details. Friendly, Sven Luther ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr