From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTP id 588315D4 for ; Thu, 6 Sep 2018 13:17:56 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.53,338,1531778400"; d="scan'208";a="345251190" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 06 Sep 2018 15:17:53 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 78058824DC; Thu, 6 Sep 2018 15:17:53 +0200 (CEST) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 81FD8824B5 for ; Thu, 6 Sep 2018 15:17:45 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=garrigue@math.nagoya-u.ac.jp; spf=None smtp.mailfrom=garrigue@math.nagoya-u.ac.jp; spf=None smtp.helo=postmaster@ms.math.nagoya-u.ac.jp IronPort-PHdr: =?us-ascii?q?9a23=3AExBknBdZqO8CNTsnzva8lqkPlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxcW4Yx7h7PlgxGXEQZ/co6odzbaO7Oa4ASQp2tWoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7?= =?us-ascii?q?Ovr6GpLIj8Swyuu+54Dfbx9HiTahY75+Ngm6oRnMvcQKnIVuLbo8xAHUqXVSYe?= =?us-ascii?q?RWwm1oJVOXnxni48q74YBu/SdNtf8/7sBMSar1cbg2QrxeFzQmLns65Nb3uhnZ?= =?us-ascii?q?TAuA/WUTX2MLmRdVGQfF7RX6XpDssivms+d2xSeXMdHqQb0yRD+v9LlgRgP2hy?= =?us-ascii?q?gbNj456GDXhdJ2jKJHuxKquhhzz5fJbI2JKPZye6XQds4YS2VcRMZcTzBODYyh?= =?us-ascii?q?YYUPDeUPM+lWoYrzp1UQqhWzHhWsCeHqyjNUhn/6wbM23uI8Gg/GxgwgGNcOvW?= =?us-ascii?q?zQotrvKKgSSP21w7fTzT7ebv1Zwy396JLJchAuvPGDQ697fM3eyUY1DQPFlFSQ?= =?us-ascii?q?qYP4PzyLzekNtnKU7/ZgVe61jW4osQ5xoj+vx8g2k4XJm5gZxUrY+iljwoY1Pc?= =?us-ascii?q?S1RUhmatCqF5tQsjuVN4pwQs46QmFovjw6yrwctpKhcigK0pIqzAPcZfyfa4WE?= =?us-ascii?q?/xzuWeiLLTp5nn5pZbyyiwqo/US91+HwTsm53VVQoiZYktTBtWoB2wHN5sWEUP?= =?us-ascii?q?dx40es1DSJ2gvO8O9LO1o0mrDeK5M5wr4/iJ4TsUPbEy/zg0X6lqqWeV84+uio?= =?us-ascii?q?8ejnZK/pppCbN450kA7yK7kultalDuskKAQOXXCb9fy91L3l40L5XK1HguA4n6?= =?us-ascii?q?TXqpzXJN4XqrO3DgNJyIov9guzAy+j0NsCnHkHKFxFeAiAj4jsI1zOL+r3De2l?= =?us-ascii?q?g1Stnzdr2u7JM6bkAprXMnjDkK3tfbBn5E5TzwoyzcpQ64tJCr0bOv38RlX9tN?= =?us-ascii?q?7ADhMhKQy73/7nCMlh1oMZQW+AHrWWMKbWsVOR4uIvIvKMZJMOtTbmK/kl4ubu?= =?us-ascii?q?gmUjlV8ce6mpx5oXZ2qiEvRoOUWTeWDsjcsZEWcWogo+S/TniEGYXj5IfHayXr?= =?us-ascii?q?kx5zA6CIKjFojDXJqijKaA3Ce9BJ1WZ3pJBkqCEXfyJM24XKIhbjiTKcgprjUf?= =?us-ascii?q?TrnpH4InzxCls0nmwqF8L8LV/DcZvNTtzo4myffUkEQQ/DdtEsmGm06EVXt1kX?= =?us-ascii?q?4FD2s51bploENgx3+G2LR4xfpRGttC7rZUFA4xc5zEmb8pQ+vuUx7MK4/aAG2t?= =?us-ascii?q?Rc+rVHRoFopoko0+Jn1lEtDntSjtmi+jArsbjbuOXsVm96vA3z73Lsl62n+Dye?= =?us-ascii?q?8ohB8kWpkXbDH0tutE7wHWQrXxvQCBja/wLPYZ1TLNsmGKwm2ftQRFFgd7F6fd?= =?us-ascii?q?DyhGOxnm6O/h70aHdIeATLQqNgwblZyHMe1PY8Hpy1NPS/DyMZHDJWu63WWoV0?= =?us-ascii?q?6F?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CjAACUKJFblwuCBoVAGhoBAQEBAQIBA?= =?us-ascii?q?QEBCAEBAQGEMwNqEiiMY41OmCkBCiOESQKDcwYGNBQBAgEBAgEBAQEBEwEBAQE?= =?us-ascii?q?BCBYGTAyCNSQBgl4BAQEDAToGAQE3AQQLCxguVwaDNAGBeQcQNKBugh2CdQEBB?= =?us-ascii?q?YFwgnUZggIIinWCAIE5H4IeLoMbBBiEeYImhi0Hhws/L41GCYY2iUkXggiGTIY?= =?us-ascii?q?TizKFZ4JjgViBdk04OyoBgkEJNYFbGoUMgUiBGoZBYAGNZgEB?= X-IPAS-Result: =?us-ascii?q?A0CjAACUKJFblwuCBoVAGhoBAQEBAQIBAQEBCAEBAQGEMwN?= =?us-ascii?q?qEiiMY41OmCkBCiOESQKDcwYGNBQBAgEBAgEBAQEBEwEBAQEBCBYGTAyCNSQBg?= =?us-ascii?q?l4BAQEDAToGAQE3AQQLCxguVwaDNAGBeQcQNKBugh2CdQEBBYFwgnUZggIIinW?= =?us-ascii?q?CAIE5H4IeLoMbBBiEeYImhi0Hhws/L41GCYY2iUkXggiGTIYTizKFZ4JjgViBd?= =?us-ascii?q?k04OyoBgkEJNYFbGoUMgUiBGoZBYAGNZgEB?= X-IronPort-AV: E=Sophos;i="5.53,338,1531778400"; d="scan'208";a="345251078" Received: from bsd20.math.nagoya-u.ac.jp (HELO ms.math.nagoya-u.ac.jp) ([133.6.130.11]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 15:17:30 +0200 Received: from [192.168.0.12] (58x158x128x157.ap58.ftth.ucom.ne.jp [58.158.128.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id F03CD89C8CD; Thu, 6 Sep 2018 22:17:27 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=math.nagoya-u.ac.jp; s=20160220; t=1536239848; bh=2NyWPM9+nD/y4uds2DmcvlhLkur+RllDzEPQsywFE6A=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=nBtIA/Akyx/EpDWFh1Wy4hmPu3a8H/XMI0w7PNmHv19GAkEvQrp9iN/YW1aN8xL4j zX3sXqczakKehHE9xycFJA0f3DeVurXJxu69WBobKUMEndM8lDEqgh3L9Mwef0iET/ Uggn1ua5LGxd+EDjNdNp6+7pIOUEXvD7VVfIO8Gs= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) From: Jacques Garrigue In-Reply-To: <20180906130314.ymqnpcxbrz5d7tj4@gargamel> Date: Thu, 6 Sep 2018 22:17:25 +0900 Cc: Mailing List OCaml Content-Transfer-Encoding: 7bit Message-Id: <5972F2FD-82AA-4C68-BE0A-D913A2D08658@math.nagoya-u.ac.jp> References: <20180906113622.lcuamhs6g6juv2r5@gargamel> <20180906130314.ymqnpcxbrz5d7tj4@gargamel> To: Enrico Tassi X-Mailer: Apple Mail (2.3445.9.1) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.2 (ms.math.nagoya-u.ac.jp [0.0.0.0]); Thu, 06 Sep 2018 22:17:28 +0900 (JST) X-Virus-Scanned: clamav-milter 0.99.2 at bsdserver20 X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on bsdserver20.math.nagoya-u.ac.jp Subject: Re: [Caml-list] How to rename a record field Reply-To: Jacques Garrigue X-Loop: caml-list@inria.fr X-Sequence: 17053 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 2018/09/06 22:03, Enrico Tassi wrote: > > On Thu, Sep 06, 2018 at 01:48:23PM +0200, Gabriel Scherer wrote: >> MPR#7102: Ability to re-export a variant definition with renamed >> constructors? >> https://caml.inria.fr/mantis/view.php?id=7102 > > Thanks for the pointer, but I'm not sure I understand how the arguments > made there apply to records. Records being the dual of variants, all the arguments apply. Namely, if the name is allowed to change, field access can no longer be seen as the intuitive projection (by name rather than position, since only name information is available in the source code). Field name disambiguation works in the same way too. There is also the same problem with GADTs assuming that two record types with different field names are distictinct. The fact the representation is identical is just an implementation detail. Tuples too share the same representation. Jacques Garrigue > My intuition is that, given that records are compared by name, there > should be no difference between adding the equation t = old or > casting (with Obj.magic) each and every term of type old to type t. > To my knowledge the two records have the very same representation at run > time, that does not depend on the names of the fields but just their > types. > > I've even tried to disable the check in typing/includecore.ml around > line 230 and the following silly test seems to work. > > type old = { bad : int; stuff : bool } > type t = old = { good : int; stuff : bool } > > let rb = { bad = 3; stuff = false } > let rg = { good = 3; stuff = false } > > let _ = Printf.printf "%b\n" rb.stuff > let _ = Printf.printf "%b\n" rg.stuff > let _ = Printf.printf "%d\n" rb.bad > let _ = Printf.printf "%d\n" rg.good > let _ = Printf.printf "%d\n" rg.bad > let _ = Printf.printf "%d\n" rb.good > let _ = Printf.printf "%d\n" { rb with good = rb.bad + 1 }.bad > let _ = Printf.printf "%b\n" { rb with stuff = not rg.stuff }.stuff > > Where is my intuition wrong? > > Why records needs to be compared by name and not by (type) structure? > Sorry if the question is silly, but I really don't know. > > Best, -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs