From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 4D653BBC1 for ; Mon, 3 Mar 2008 17:56:05 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAADO8y0c+BBBlnmdsb2JhbACBVo8cAQEBAQEGBAYHChibdw X-IronPort-AV: E=Sophos;i="4.25,438,1199660400"; d="scan'208";a="8903214" Received: from smtp-101-monday.nerim.net (HELO kraid.nerim.net) ([62.4.16.101]) by mail1-smtp-roc.national.inria.fr with ESMTP; 03 Mar 2008 17:56:05 +0100 Received: from hector.lesours (ours.starynkevitch.net [213.41.244.95]) by kraid.nerim.net (Postfix) with ESMTP id A7F6ACFA08; Mon, 3 Mar 2008 17:56:04 +0100 (CET) Received: from [192.168.0.1] (glinka.lesours [192.168.0.1]) by hector.lesours (Postfix) with ESMTP id 4051220F0FE; Mon, 3 Mar 2008 17:55:23 +0100 (CET) Message-ID: <47CC2D9F.6050109@starynkevitch.net> Date: Mon, 03 Mar 2008 17:55:59 +0100 From: Basile STARYNKEVITCH User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080109) MIME-Version: 1.0 To: mfmorss@aep.com Cc: caml-list caml-list Subject: Re: [Caml-list] different records, same field name? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; basile:01 basile:01 toplevel:01 compiler:01 inference:01 faiencerie:01 92340:01 reine:01 wrote:01 caml-list:01 int:01 int:01 define:02 8501:02 2359:02 mfmorss@aep.com wrote: > > In any case, is it possible to define and use different types of records, > which nevertheless share some field names? I have had difficulty doing > this in the toplevel. It is not possible, for a simple reason: Suppose you have two record type tr1 & tr2 sharing a common field name f type tr1 = { f : int; f1 : string } type tr2 = { f2 : float; f: int } Then the compiler won't be able to infer the type of function ff retrieving this field f let ff x = x.f So the requirement that each field name is different is the price to pay to have type inference. Regards -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***