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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id AB593BBAF for ; Sun, 9 Aug 2009 15:55:19 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoYCAFhyfkrUGyoFkWdsb2JhbACaSgEBAQEJCwoHEwOwb4QYBYIn X-IronPort-AV: E=Sophos;i="4.43,349,1246831200"; d="scan'208";a="34203045" Received: from smtp5-g21.free.fr ([212.27.42.5]) by mail1-smtp-roc.national.inria.fr with ESMTP; 09 Aug 2009 15:55:18 +0200 Received: from smtp5-g21.free.fr (localhost [127.0.0.1]) by smtp5-g21.free.fr (Postfix) with ESMTP id CED47D480FD; Sun, 9 Aug 2009 15:55:13 +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 D9376D480CF; Sun, 9 Aug 2009 15:55:10 +0200 (CEST) Message-ID: <4A7ED53B.90607@frisch.fr> Date: Sun, 09 Aug 2009 15:55:07 +0200 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3pre) Gecko/20090808 Shredder/3.0b4pre MIME-Version: 1.0 To: ivan chollet Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: ocaml sefault in bytecode: unanswered questions References: <000301ca184b$032b8cc0$0982a640$@chollet@free.fr> <000701ca184d$29507e90$7bf17bb0$@metastack.com> <001001ca18c7$37b22220$a7166660$@chollet@free.fr> <001501ca18cc$d59a61a0$80cf24e0$@metastack.com> <001201ca18e9$c4456810$4cd03830$@chollet@free.fr> In-Reply-To: <001201ca18e9$c4456810$4cd03830$@chollet@free.fr> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; frisch:01 frisch:01 ocaml:01 bytecode:01 pervasives:01 recursive:01 2009:98 equality:01 equality:01 wrote:01 caml-list:01 alain:01 alain:01 functional:02 traversal:03 On 8/9/2009 2:06 PM, ivan chollet wrote: > I would have thought physical equality implies structural equality, but > it doesn’t seem like it. > > Can you please explain to me what’s wrong there? There are two modes for the generic comparison. The total mode (Pervasives.compare) creates a total ordering between values (except for functional values and custom blocks with no comparison function) and uses physical equality as a shortcut to cut the recursive traversal of sub-values. The non-total mode (used by the operators = < > <= >=) has a different behavior for NaN values ([nan <= x], [x <= nan], and [nan = x] all return false, including when x is nan) and does not use the physical equality shortcut (so that [let x = (nan, nan) in x = x] returns false). -- Alain