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 LAA17285; Sat, 28 Feb 2004 11:22:02 +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 LAA16140 for ; Sat, 28 Feb 2004 11:22:01 +0100 (MET) Received: from smtp.web.de (smtp03.web.de [217.72.192.158]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i1SAM6Iq027684 for ; Sat, 28 Feb 2004 11:22:06 +0100 Received: from [213.6.74.64] (helo=wiko) by smtp.web.de with smtp (WEB.DE 4.99 #605) id 1Ax1bB-0008Oj-00; Sat, 28 Feb 2004 11:21:33 +0100 Message-ID: <009401c3fde4$a4f58330$404a06d5@wiko> From: "Andreas Rossberg" To: "Michal Moskal" , References: <20040227225931.GA9161@roke.freak> <20040228094034.81565.qmail@web41905.mail.yahoo.com> <20040228095652.GA10435@roke.freak> Subject: Re: [Caml-list] Semantics of physical equality Date: Sat, 28 Feb 2004 11:21:35 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 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; rossberg:01 caml-list:01 michal:01 moskal:01 malekith:01 pld-linux:01 semantics:01 ints:01 ints:01 equality:01 equality:01 mutable:01 mutable:01 int:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Michal Moskal wrote: > > type test = > > { > > mutable a:int; > > b:int > > };; > > > > let r = {a=0;b=2};; > > > > let x = r and y = r in > > assert((x.a==y.a)&&(x.b==y.b)&&(x==y)) > > ;; > > > > Does this always ok ? > > Yes, of course. The objects x and y are physically equal (which implies > physical equality of their fields). No, because (x.a == x.a) is not comparing the fields themselves (you cannot do that, fields are not first class), but the projected values. They may be physically different. Consider: type r = {mutable a : float} let r = {a = 1.0} let b = x.a == x.a This will deliver false. > But both r.a and r.b are ints, so it is always OK (== and = are the same > on ints). That is what the current implementation does, but it is not guaranteed. - Andreas ------------------- 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