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 UAA25972; Thu, 8 Nov 2001 20:13:07 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 UAA26043 for ; Thu, 8 Nov 2001 20:13:05 +0100 (MET) Received: from smtp2.cswv.com (smtp2.cswv.com [4.17.129.20]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id fA8JD5X04939 for ; Thu, 8 Nov 2001 20:13:05 +0100 (MET) Received: from smtp2.cswv.com ([10.2.3.6]) by smtp2.cswv.com with Microsoft SMTPSVC(5.5.1877.197.19); Thu, 8 Nov 2001 14:12:59 -0500 Received: FROM exchange1.cswv.com BY smtp2.cswv.com ; Thu Nov 08 14:12:58 2001 -0500 Received: by exchange1.cswv.com with Internet Mail Service (5.5.2653.19) id ; Thu, 8 Nov 2001 14:16:37 -0500 Message-ID: From: "Krishnaswami, Neel" To: "'Will Benton'" , caml-list@pauillac.inria.fr Subject: RE: [Caml-list] Some things are more equal than others Date: Thu, 8 Nov 2001 14:16:34 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Will Benton [mailto:willb@cs.wisc.edu] wrote: > On Thu, 2001-11-08 at 12:34, Jim Farrand wrote: > > I know that this is almost certainly a case of RTFM, but I > > can't seem to find the right place. 6.7.4 mentions "structural" and > > "physical" equality, but doesn't define either. > > Someone on the list will correct me if I'm wrong, but to clarify your > guess (which seems correct to me): Physical equality is a pointer > comparison -- i.e. "do these objects occupy the same memory location". This is correct. (The one filip is that for unboxed integers the requirement is that the bit pattern in the words be the same, since they aren't pointers.) > I have assumed that, by "Structural equality", they mean *shallow* > equivalence -- i.e. "do these objects have the same structure, but not > necessarily the same content". Is this correct? This is not so. Eg, # [1, 2, 3] = [1, 2, 3];; - : bool = true; # [1, 2, 3] = [1, 2, 8];; - : bool = false; What (=) does is rather like the Scheme equal? predicate. It walks down the structure of the two objects you are comparing, and makes sure that the whole thing is equal. This means that you can trick it into hanging with recursive structures: type foo = Foo of foo let rec x = Foo x let rec y = Foo y Then the expression (x = y) will not terminate, since the (=) predicate will loop as it chases pointers infinitely. -- Neel Krishnaswami neelk@cswcasa.com ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr