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 WAA22574; Fri, 27 Feb 2004 22:32:32 +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 WAA22983 for ; Fri, 27 Feb 2004 22:32:31 +0100 (MET) Received: from mallaury.noc.nerim.net (smtp-105-friday.noc.nerim.net [62.4.17.105]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i1RLWZIq020122 for ; Fri, 27 Feb 2004 22:32:35 +0100 Received: from hector.lesours (ours.starynkevitch.net [213.41.130.15]) by mallaury.noc.nerim.net (Postfix) with ESMTP id 7F65362D41; Fri, 27 Feb 2004 22:32:27 +0100 (CET) Received: from basile by hector.lesours with local (Exim 4.30) id 1Awpav-0000oG-Sf; Fri, 27 Feb 2004 22:32:29 +0100 Date: Fri, 27 Feb 2004 22:32:29 +0100 To: "Kevin S. Millikin" , caml-list@inria.fr Subject: Re: [Caml-list] Semantics of physical equality Message-ID: <20040227213229.GA2962@ours.starynkevitch.net> References: <01C3FD3E.290EEEB0.kmillikin@atcorp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=unknown-8bit Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <01C3FD3E.290EEEB0.kmillikin@atcorp.com> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Basile STARYNKEVITCH X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 basile:01 basile:01 2004:99 0600,:01 runtime:01 hash-consing:01 coder:01 3.07:01 hypothesis:01 demonstrate:01 faiencerie:01 92340:01 reine:01 compiler:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Feb 27, 2004 at 02:29:50PM -0600, Kevin S. Millikin wrote: > I'm trying to figure out what I can rely on about physical equality. > I've checked the OCaml manual but can't seem to find what I want to > know. > > Presume > > # type t = V0 | V1 of int;; > type t = V0 | V1 of int > > # V0 == V0;; > - : bool = true > > V0's are the same. Is this guaranteed? Yes. > > # V1(0) == V1(0);; > - : bool = false > > V1's are different. Is this guaranteed? What do you mean by guaranteed? This is true, but it might become false: a) because the compiler optimize a common constant subexpression b) because the runtime might make these 2 values become the same (ie by hash-consing). c) there is a tricky issue regarding floating point compares for NaN. Read the source code or some previous posting on this (I never used NaN since I am not a numerical coder). As far as I know, neither a nor b is currently true (both in Ocaml3.07pl2 and in the latest CVS), but I could imagine that some later version of ocaml might do a or b (even if I believe this unlikely). The only reasonable implication about physical equality is a == b implies a = b (ie physical equality implies structural equality) Why would you want a guarantee that V1 0 is not physically equal to V1 0? I tend to think that making such an hypothesis is dangerous and wrong, even if the current implementation demonstrate it. Regards. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basilestarynkevitchnet aliases: basiletunesorg = bstarynknerimnet 8, rue de la Faïencerie, 92340 Bourg La Reine, France ------------------- 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