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.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id C822DBC37 for ; Wed, 29 Jul 2009 08:13:51 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvgBAEuFb0rUGyoFkWdsb2JhbACaCgEBAQEJCwoHEwO6H4QQBYlo X-IronPort-AV: E=Sophos;i="4.43,287,1246831200"; d="scan'208";a="44083155" Received: from smtp5-g21.free.fr ([212.27.42.5]) by mail4-smtp-sop.national.inria.fr with ESMTP; 29 Jul 2009 08:13:50 +0200 Received: from smtp5-g21.free.fr (localhost [127.0.0.1]) by smtp5-g21.free.fr (Postfix) with ESMTP id 7E4EFD48101; Wed, 29 Jul 2009 08:13:44 +0200 (CEST) Received: from [82.229.183.156] (rke75-3-82-229-183-156.fbx.proxad.net [82.229.183.156]) by smtp5-g21.free.fr (Postfix) with ESMTP id 7A263D48114; Wed, 29 Jul 2009 08:13:42 +0200 (CEST) Message-ID: <4A6FE88E.7020801@frisch.fr> Date: Wed, 29 Jul 2009 08:13:34 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2pre) Gecko/20090727 Shredder/3.0b4pre MIME-Version: 1.0 To: Elnatan Reisner Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Physical counterpart to Pervasives.compare? References: <1501.208.59.169.96.1248830737.squirrel@webmail.cs.umd.edu> In-Reply-To: <1501.208.59.169.96.1248830737.squirrel@webmail.cs.umd.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 pervasives:01 pervasives:01 ocaml:01 hashing:01 val:01 mutable:01 2009:98 polymorphic:01 wrote:01 heap:01 caml-list:01 compares:01 alain:01 On 7/29/2009 3:25 AM, Elnatan Reisner wrote: > Is there something that can complete this analogy: > (=) is to (==) as Pervasives.compare is to ___? > > That is, is there a polymorphic total ordering with respect to *physical* > entities, rather than to their structure? Not really. The physical location of heap values is not stable (because of the GC), so you cannot use it as a total ordering. It may be useful to know that the generic structural comparison has a physical behavior for OCaml objects (it compares their unique ids). So wrapping your values inside objects can be a good trick to get physical comparison (and hashing), as in: class ['a] physical_reference init = object val mutable current : 'a = init method get = current method set x = current <- x end -- Alain