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 XAA16975; Sun, 7 Apr 2002 23:24:12 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA10557 for caml-list@pauillac.inria.fr; Sun, 7 Apr 2002 23:24:11 +0200 (MET DST) 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 SAA10997 for ; Sun, 7 Apr 2002 18:43:51 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from sj1-3-4-9.securesites.net (sj1-3-4-9.securesites.net [192.220.127.202]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g37GhjX12353 for ; Sun, 7 Apr 2002 18:43:46 +0200 (MET DST) Received: (qmail 27022 invoked by uid 16863); 7 Apr 2002 16:43:44 -0000 Received: from unknown (HELO localhost) ([192.220.65.223]) (envelope-sender ) by 192.220.65.223 (qmail-ldap-1.03) with SMTP for ; 7 Apr 2002 16:43:44 -0000 Date: Sun, 7 Apr 2002 16:43:44 +0000 (GMT) From: Brian Rogoff To: Oliver Bandel cc: caml-list@inria.fr Subject: Re: [Caml-list] Records with same structure in OCaml In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 6 Apr 2002, Oliver Bandel wrote: > Hello, > > > when I use two records with the same structure, > how can they be distinguished? And how can > the correct type be choosed? This question comes up frequently enough to be a FAQ entry http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html#labels_surcharge and the most frequent answer is "Don't do that!", meaning either disambiguate the field names if the records are defined in the same module type complex = { complex_re: float; complex_im: float }; type foo = { foo_re: float; foo_im: float }; or put each definition in its own module and use the fully qualified name if you must mix them. You can also use classes, but if you're a performance junkie you should realize that you give up a lot of performance, especially in the example you use, complex numbers. You also lose pattern matching (and gain some polymorphism) is you use the class system. -- Brian ------------------- 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