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 B418FBBAF for ; Thu, 13 Jul 2006 04:41:20 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id k6D2fKlq019383 for ; Thu, 13 Jul 2006 04:41:20 +0200 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 EAA08792 for ; Thu, 13 Jul 2006 04:41:19 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k6D2f8rL031167 for ; Thu, 13 Jul 2006 04:41:18 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.7/8.13.6) with ESMTP id k6D2f21E024838; Thu, 13 Jul 2006 11:41:02 +0900 (JST) Date: Thu, 13 Jul 2006 11:43:39 +0900 (JST) Message-Id: <20060713.114339.07638100.garrigue@math.nagoya-u.ac.jp> To: ebreck@cs.cornell.edu Cc: caml-list@inria.fr Subject: Re: [Caml-list] changing the type of records using "with" From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 44B5B2D0.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44B5B2C4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; foo:01 foo:01 val:01 val:01 ocaml:01 intentional:01 polymorphic:01 cornell:01 caml-list:01 typing:01 behaviour:01 argument:01 jacques:01 jacques:01 int:01 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 From: Eric Breck > I noticed the following behavior of the typing system: > > # type 'a foo = {a: 'a; b: int};; > type 'a foo = { a : 'a; b : int; } > # let one = { a = (); b = 5};; > val one : unit foo = {a = (); b = 5} > # let two = {one with a = "Hello"};; > val two : string foo = {a = "Hello"; b = 5} > > i.e. "{one with ... }" can have a different polymorphic type argument > than "one" does. This has been handy for me on a couple of > occasions, but is it a documented feature that I can count on working > in future versions of ocaml, or is it a quirk of the current version? This behaviour is intentional. My interpretation of the reference manual is that {one with a = "Hello"} should be strictly equivalent to {a = "Hello"; b = one.b}. As a result I would say that requiring two.a and one.a to have the same type would depart from this specification. Jacques Garrigue