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 TAA13238; Sun, 27 Oct 2002 19:02:16 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA14073 for ; Sun, 27 Oct 2002 19:02:15 +0100 (MET) Received: from mel-rto3.wanadoo.fr (smtp-out-3.wanadoo.fr [193.252.19.233]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g9RI2FD17856 for ; Sun, 27 Oct 2002 19:02:15 +0100 (MET) Received: from mel-rta9.wanadoo.fr (193.252.19.69) by mel-rto3.wanadoo.fr (6.5.007) id 3DA24D1800C0DEFD for caml-list@inria.fr; Sun, 27 Oct 2002 19:02:14 +0100 Received: from debian (80.8.84.231) by mel-rta9.wanadoo.fr (6.5.007) id 3DA24B2900C7D63F for caml-list@inria.fr; Sun, 27 Oct 2002 19:02:14 +0100 Received: from moi by debian with local (Exim 3.36 #1 (Debian)) id 185rjs-0001Hw-00 for ; Sun, 27 Oct 2002 19:02:16 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] On the equality of functional values References: <3DBBF3F3.8080600@baretta.com> Mail-Copy-To: never From: Remi VANICAT Date: Sun, 27 Oct 2002 19:02:16 +0100 In-Reply-To: <3DBBF3F3.8080600@baretta.com> (Alessandro Baretta's message of "Sun, 27 Oct 2002 15:10:59 +0100") Message-ID: <87lm4jdal3.dlv@wanadoo.fr> User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (i386-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Alessandro Baretta writes: > I have been experimenting with equal signs, and I noticed that the > equality operator (=) behaves in a strange way with respect to > functional values. > > Objective Caml version 3.06 > > # (=) = (=) ;; > Exception: Invalid_argument "equal: functional value". > # let x = (=) in x = x ;; > - : bool = true > > The first line seems to imply that no comparisons are possible between > functional values. However, the second line I typed does not raise the > same exception. This seems to imply that comparisons are allowed > between functional values, too. > > Now, which of two hypotheses is correct? The first one. But the fact is that before making a structural equality test, ocaml try to see if both argument have the same address, and then return true, so equality may work if both argument are exactly the same closure. (then, there is a subtlety : the = function is a c function, not a caml one. So when one refer to (=), caml build a new fresh closure, that is different from any other closure). (and there is another subtlety, making executable generated by ocaml and by ocamlopt having some subtle difference in this case). -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners