From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA00384; Mon, 23 Apr 2001 09:18:57 +0200 (MET DST) 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 JAA00390 for ; Mon, 23 Apr 2001 09:18:56 +0200 (MET DST) Received: from ext.lri.fr (ext.lri.fr [129.175.15.4]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f3N7Itf18883 for ; Mon, 23 Apr 2001 09:18:55 +0200 (MET DST) Received: from pc803.lri.fr (IDENT:root@pc803 [129.175.8.114]) by ext.lri.fr (8.11.1/jtpda-5.3.2) with ESMTP id f3N7Ip516923 ; Mon, 23 Apr 2001 09:18:53 +0200 (MET DST) Received: by pc803.lri.fr (8.9.3/feuille) id JAA04183 ; Mon, 23 Apr 2001 09:01:10 +0200 X-Authentication-Warning: localhost.localdomain: filliatr set sender to filliatr@pc803 using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15075.54065.253514.205217@pc803> Date: Mon, 23 Apr 2001 09:01:05 +0200 (MEST) To: Georges Brun-Cottan Cc: caml-list@inria.fr Subject: Re: [Caml-list] equality over functional value In-Reply-To: <200104202012.QAA09326@lub0127.lss.emc.com> References: <200104202012.QAA09326@lub0127.lss.emc.com> X-Mailer: VM 6.49 under Emacs 20.4.1 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Georges Brun-Cottan writes: > > Hi, > > A friend of mine is just starting with ocaml. He was puzzled by the > following result: > > # let a i = i;; > val a : 'a -> 'a = > # let b i = i;; > val b : 'a -> 'a = > # a=b;; > Uncaught exception: Invalid_argument "equal: functional value". > # a=a;; > - : bool = true > # > > That is 'a=a' does not return the expected exception. Actually it > first hit this "curiosity" when creating a polymorphic 'sort' function > on lists - and by applying it to a [sort;sort..] list. It worked. > > Is this a bug? I don't think this behavior is intentional, but it has an easy explanation: for better efficiency, the structural comparison function (in byterun/compare.c) first tries physical equality, and then structural equality if there is no physical equality. So in the case of a=a, the answer is true because of physical equality. Hope this helps, -- Jean-Christophe FILLIATRE mailto:Jean-Christophe.Filliatre@lri.fr http://www.lri.fr/~filliatr ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr