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 JAA15823; Tue, 11 May 2004 09:31:47 +0200 (MET DST) 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 JAA15911 for ; Tue, 11 May 2004 09:31:46 +0200 (MET DST) Received: from oxy.exomi.com (fa-3-0-0.fw.exomi.com [217.169.64.99]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4B7VjEV025400 for ; Tue, 11 May 2004 09:31:45 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by oxy.exomi.com (Postfix) with ESMTP id E60411FEB71; Tue, 11 May 2004 10:32:51 +0300 (EEST) In-Reply-To: <16544.24810.112188.634596@soggy.deldotd.com> References: <16544.24810.112188.634596@soggy.deldotd.com> Mime-Version: 1.0 (Apple Message framework v613) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <68643590-A31D-11D8-A8EF-000393863F70@exomi.com> Content-Transfer-Encoding: 7bit Cc: caml-list@inria.fr From: Ville-Pertti Keinonen Subject: Re: [Caml-list] duplicate record labels and modules Date: Tue, 11 May 2004 10:32:50 +0300 To: briand@aracnet.com X-Mailer: Apple Mail (2.613) X-Miltered: at nez-perce with ID 40A08161.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 foo:01 foo:01 printf:01 printf:01 verbose:01 labels:01 modules:02 modules:02 unbound:02 module:03 module:03 typing:03 wrote:03 slightly:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On May 11, 2004, at 8:13 AM, briand@aracnet.com wrote: > Consider the following : > > let a = {Foo.n1=1; Foo.n2=2; Foo.a=(- 1.0)} in > let b = {Bar.n1=4; Bar.n2=(- 5); Bar.b=77.} in > Printf.printf "%d\n" a.Foo.n1; > Printf.printf "%d\n" b.Bar.n1; If you want to make it slightly less verbose, you can say module F = Foo module B = Bar Or you could use "let module ... in". Alternately, assuming the modules are your own, you can name your record fields so that opening both modules doesn't cause conflicts (e.g. using a short prefix). > let (a:Foo.t) = {n1=1; n2=2; a=(- 1.0)} in > > Unbound record field label n1 > > After careful review of the grammar I discovered that is incorrect, > although it seems like it should work. Nothing about "a" affects the meaning of the expression on the right hand side of the "=". Even if it did, the visibility of identifiers is determined only by lexical scope, typing has no effect, which is why even if you have "a:Foo.t" in scope, you can't access "a.n1". ------------------- 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