From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 65D74BBAF for ; Sat, 21 Nov 2009 16:55:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtIAAOabB0tRZ90wkWdsb2JhbACQGYtuAQEBAQkLCgcTA7Z4hDwE X-IronPort-AV: E=Sophos;i="4.47,264,1257116400"; d="scan'208";a="38510431" Received: from mtaout02-winn.ispmail.ntl.com ([81.103.221.48]) by mail3-smtp-sop.national.inria.fr with ESMTP; 21 Nov 2009 16:55:46 +0100 Received: from aamtaout04-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20091121155545.LOEI27507.mtaout02-winn.ispmail.ntl.com@aamtaout04-winn.ispmail.ntl.com>; Sat, 21 Nov 2009 15:55:45 +0000 Received: from romulus.metastack.com ([81.102.132.77]) by aamtaout04-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20091121155545.JKYS22934.aamtaout04-winn.ispmail.ntl.com@romulus.metastack.com>; Sat, 21 Nov 2009 15:55:45 +0000 Received: from COUNTERTENOR (genkt-048-012.t-mobile.co.uk [149.254.48.12]) (authenticated bits=0) by romulus.metastack.com (8.14.2/8.14.2) with ESMTP id nALFtUXh010620 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Sat, 21 Nov 2009 15:55:38 GMT From: "David Allsopp" To: "'Mykola Stryebkov'" , References: In-Reply-To: Subject: RE: [Caml-list] Same name fields Date: Sat, 21 Nov 2009 15:55:32 -0000 Message-ID: <000001ca6ac3$13a30c20$3ae92460$@allsopp@metastack.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acpqv+9ToxT8QUJ9R16y+Mk5553wrwAAkczQ Content-Language: en-gb Organization: MetaStack Solutions Ltd. X-Scanned-By: MIMEDefang 2.65 on 81.102.132.77 X-Cloudmark-Analysis: v=1.0 c=1 a=n06BfVqjAAAA:20 a=yaji0bSXa3REhWnvwJkA:9 a=sl2vGH2eSUxyfpRUOWIA:7 a=OlLPCOWlJCi9HD3kqxAp5bZtGvwA:4 X-Spam: no; 0.00; bug:01 beginners':01 ocaml:01 beginners:01 wrote:01 unix:01 caml-list:01 prefixes:01 modules:02 snip:02 groups:02 confusing:02 objects:02 module:03 module:03 Mykola Stryebkov wrote: > I'm trying to declare to record types with fields having the same name > but different types. This is not possible with record types (at the same module scope) - when you declare the second type you obscure the previous type. > If I declare type ta second - everything works fine. > Is it a bug? No :o) > If not, what is an appropriate workaround here? Either put types ta and tb in separate modules (then you can use qualified field names) or use different field names. The Unix module in the Standard Library is a good example of how to do all this in practice - the record types there all have standard prefixes on the field names. The other alternative is to use objects but this is heavier in terms of memory and field access and the type errors messages are more confusing than with records (but neither of these reasons are necessarily bars to using them!!). David PS Not that it I think it generally offends people on this list, but this question would have been more appropriate for the Beginners' List - http://groups.yahoo.com/group/ocaml_beginners