From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 5FD48BC48 for ; Fri, 1 Apr 2005 06:31:11 +0200 (CEST) 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 j314VAO6016875 for ; Fri, 1 Apr 2005 06:31:10 +0200 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 GAA23370 for ; Fri, 1 Apr 2005 06:31:10 +0200 (MET DST) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j314V85s016868 for ; Fri, 1 Apr 2005 06:31:09 +0200 Received: from localhost (millas [172.16.30.29]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id j314UqXN028953; Fri, 1 Apr 2005 13:30:52 +0900 (JST) Date: Fri, 01 Apr 2005 13:29:56 +0900 (JST) Message-Id: <20050401.132956.74753023.garrigue@math.nagoya-u.ac.jp> To: er@cs.brown.edu Cc: yminsky@cs.cornell.edu, caml-list@inria.fr Subject: Re: [Caml-list] Another polymorphism puzzle From: Jacques Garrigue In-Reply-To: <20050401025205.GA4723@cs.brown.edu> References: <891bd339050331180214df95db@mail.gmail.com> <20050401025205.GA4723@cs.brown.edu> X-Mailer: Mew version 4.0.69 on Emacs 21.3.50 / 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 424CCE8E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 424CCE8C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 polymorphism:01 renieris:01 foo:01 val:01 foo:01 val:01 bug:01 expr:01 yaron:01 minsky:01 semantics:01 restrictive:01 wrote:01 typing:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: From: Manos Renieris > Worse: > > # let f x = { () with foo = 3};; > val f : 'a -> int t = > # let f x = { 42 with foo = 3};; > val f : 'a -> int t = > > I think this qualifies as a bug. Especially since the documentation > says the expr on the left hand side of with has to be a record. What do you mean by worse? You just exhibit an immediate consequence of the typing of f below. > Thu, Mar 31, 2005 at 09:02:14PM -0500, Yaron Minsky wrote: > > # type 'a t = { foo: 'a };; > > type 'a t = { foo : 'a; } > > # let f x = { x with foo = 3 };; > > val f : 'a -> int t = Now, why does it happen? The reason is simply that the typing of {x with fields} follows closely its semantics: build a record from the given fields, extracting values from x when a field is missing. Consequence: if you provide all the fields, then there is no missing field, so x can be completely ignored. Following the manual, the typing could be more restrictive, but the current typing is perfectly sound. Jacques Garrigue