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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 5BD74BB81 for ; Sat, 12 Nov 2005 17:53:27 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jACGrQLZ007985 for ; Sat, 12 Nov 2005 17:53:27 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA24664 for ; Sat, 12 Nov 2005 17:53:26 +0100 (MET) Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jACGoRNL001624 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sat, 12 Nov 2005 17:53:26 +0100 Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) by albireo.enyo.de with esmtp id 1EayaB-0002ZJ-My; Sat, 12 Nov 2005 17:50:27 +0100 Received: from fw by deneb.enyo.de with local (Exim 4.54) id 1Eaya3-0004LG-Q5; Sat, 12 Nov 2005 17:50:19 +0100 From: Florian Weimer To: Florent Cc: caml-list@inria.fr Subject: Re: [Caml-list] strange behavior with record type definition References: <43752259.80800@aist.enst.fr> <4375CAC8.5030803@aist.enst.fr> <1131797575.18524.0.camel@rosella> <4375DDFC.9060802@motion-twin.com> <1131799890.18524.14.camel@rosella> <4375FACF.3040906@aist.enst.fr> Date: Sat, 12 Nov 2005 17:50:19 +0100 In-Reply-To: <4375FACF.3040906@aist.enst.fr> (Florent's message of "Sat, 12 Nov 2005 15:23:11 +0100") Message-ID: <87r79llsj8.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Miltered: at nez-perce with ID 43761E06.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43761D53.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 datatypes:01 datatype:01 drawbacks:01 ...:98 ...:98 workaround:01 int:01 int:01 defined:01 florian:02 ambiguous:02 inferred:02 types:02 let:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 * Florent: > Ok but with these two record types defined : > type t0 = { x : int ; y : int } ;; > type t1 = { x : int } ;; > > There is no ambiguity about the following expression's type: > { x = 0 ; y = 0 } ;; > Why can't the t0 type be infered ? Other common cases are ambiguous, for example: let proj_x v = v.x Standard ML provides what you want, and you must specify all record fields unless the record type can be inferred by other means. For example, fun proj_x v = #x v or fun proj_x { x = x, ... } = x does not type-check, you must write: fun proj_x { x = x, y = _ } = x This becomes quite cumbersome if there are more than two or three components. There is a workaround using datatypes, i.e. write datatype t0 = T0 of { x : int, y : int } and fun proj_x (T0 { x = x, ... }) = x So both approaches have their drawbacks.