From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 58B36BC50 for ; Sat, 16 Sep 2006 22:58:56 +0200 (CEST) Received: from rabbit.math.nagoya-u.ac.jp (rabbit.math.nagoya-u.ac.jp [133.6.130.5]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k8GKwsp5027215 for ; Sat, 16 Sep 2006 22:58:55 +0200 Received: from localhost (moose-172 [172.16.254.3]) by rabbit.math.nagoya-u.ac.jp (8.12.11/3.7W) with ESMTP id k8GKwO2B007773; Sun, 17 Sep 2006 05:58:25 +0900 (JST) Date: Sun, 17 Sep 2006 05:58:21 +0900 (JST) Message-Id: <20060917.055821.94069241.garrigue@math.nagoya-u.ac.jp> To: diego-olivier.fernandez-pons@cicrp.jussieu.fr Cc: caml-list@inria.fr, rossberg@ps.uni-sb.de Subject: Re: [Caml-list] Improper generic equality in Caml (Rossberg's SML vs Caml) From: Jacques Garrigue In-Reply-To: References: <20060913091435.537F4AC04@Adric.metnet.fnmoc.navy.mil> 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 discorde with ID 450C658E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; improper:01 sml:01 pons:01 pons:01 rossberg:01 sml:01 rossberg:01 ocaml:01 val:01 mutable:01 val:01 mutable:01 bool:01 structurally:01 pointer:01 From: Diego Olivier Fernandez Pons > What does Andreas Rossberg in his SML vs. Caml page > > http://www.ps.uni-sb.de/~rossberg/SMLvsOcaml.html > > mean when he says that > > [Caml] Does not have a proper generic equality > on one hand (1, r) != (1, r), on the other (1, r) = (1, ref 1) The word "proper" is a bit strange (SML-centric), but the meaning is indeed that in ocaml you need two kinds of equalities, while in SML you can do with one. You have a taste of the SML way with objects: # class c = object val mutable x = 0 method set x' = x <- x' method get = x end;; class c : object val mutable x : int method get : int method set : int -> unit end # new c = new c;; - : bool = false Namely, in SML only immutable values are compared structurally, mutable ones being compared by pointer. The main advantage is that there is no need for physical equality, knowing that physical equality sometimes allows to distinguish between things that should be identical. This is completed by the use of so-called equality types, so that you cannot use equality on abstract types, where it may break abstraction. I personally like the idea of automatically using pointer equality on mutables. However pointer equality sometimes comes as a handy optimization for immutable values too, so going a long way to exclude it from the language may seem a bit harsh. By the way, I don't think that his statement is connected with the incoherence between structural and physical equality on Nan, which is a rather recent phenomenon in ocaml. Jacques Garrigue