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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id BF660BB81 for ; Sat, 12 Nov 2005 16:32:54 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jACFWswu026671 for ; Sat, 12 Nov 2005 16:32:54 +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 QAA22262 for ; Sat, 12 Nov 2005 16:32:53 +0100 (MET) Received: from hedwig1.umh.ac.be (hedwig2.umh.ac.be [193.190.193.73]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jACFWr0f026668 for ; Sat, 12 Nov 2005 16:32:53 +0100 Received: from poincare (Debian-exim@pri-010.umh.ac.be [10.101.0.10]) by hedwig1.umh.ac.be (8.13.1/8.13.1) with ESMTP id jACFY5ab3825904; Sat, 12 Nov 2005 16:34:06 +0100 Received: from localhost ([127.0.0.1] ident=trch) by poincare with esmtp (Exim 4.54) id 1EaxMw-0003bC-Td; Sat, 12 Nov 2005 16:32:42 +0100 Date: Sat, 12 Nov 2005 16:32:42 +0100 (CET) Message-Id: <20051112.163242.20259664.debian00@tiscali.fr> To: florentflament@aist.enst.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] strange behavior with record type definition From: Christophe TROESTLER In-Reply-To: <4375FACF.3040906@aist.enst.fr> References: <4375DDFC.9060802@motion-twin.com> <1131799890.18524.14.camel@rosella> <4375FACF.3040906@aist.enst.fr> Organization: Universite de Mons-Hainaut (http://math.umh.ac.be/an/) X-Spook: Semtex eternity server Legion of Doom benelux class struggle Kosovo InfoSec broadside Bosnia brigand X-Blessing: Om Ah Hum Vajra Guru Pema Siddhi Hum X-Operating-System: GNU/Linux (http://www.linux.org/) X-Mailer-URL: http://www.mew.org/ X-Mailer: Mew version 4.2.53 on Emacs 22.0.50 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.1 (www dot roaringpenguin dot com slash mimedefang) X-j-chkmail-Score: MSGID : 43760B25.000 on concorde : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 43760B26.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43760B25.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 christophe:01 troestler:01 compiler:01 compiler:01 2005,:98 wrote:01 explicitly:01 int:01 int:01 defined:01 reorder:02 debian:02 nicolas:02 types:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=FROM_ENDS_IN_NUMS autolearn=disabled version=3.0.3 On Sat, 12 Nov 2005, Florent wrote: > > 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 ? As said by Nicolas, what would be the type of let f r = { r with x = 1 } > And with this function definition, > let get_y (t:t0) = t.x ;; > I explicitly say to the compiler that t is of type t0, so why does the > compiler infer a t1 type when trying to get the x label of a t0 type value ? Because (at this point) t.x implies t is of type t1. If you do not care to access the fields of t0 after, just reorder your definitions: type t0 = { x : int ; y : int } let get_y t = t.x type t1 = { x : int } ChriS