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 KAA04184; Fri, 8 Oct 2004 10:29:20 +0200 (MET DST) 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 KAA04168 for ; Fri, 8 Oct 2004 10:29:19 +0200 (MET DST) Received: from mailhost.tni.fr (firewall.tni.fr [195.25.255.61]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i987c5e3002571 for ; Fri, 8 Oct 2004 09:38:05 +0200 Received: from groscool.tni.fr ([195.25.255.61]) by mailhost.tni.fr (Netscape Messaging Server 3.62) with SMTP id 1552; Fri, 8 Oct 2004 09:38:12 +0200 Received: from 195.7.123.178 by groscool.tni.fr (InterScan E-Mail VirusWall NT); Fri, 08 Oct 2004 09:38:11 +0200 Message-ID: <41665FE8.8030208@tni-software.com> Date: Fri, 08 Oct 2004 09:37:44 +0000 From: =?ISO-8859-1?Q?S=E9bastien_Furic?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christophe Raffalli CC: caml-list Subject: Re: [Caml-list] Are you sure the new "=" of 3.08 is good ? References: <4165B1A5.9040208@univ-savoie.fr> In-Reply-To: <4165B1A5.9040208@univ-savoie.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 416643DD.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; furic:01 furic:01 caml-list:01 raffalli:01 phox:01 prover:01 follwing:01 predicates:01 inequality:01 nums:01 developping:01 dags:01 generic:01 generic:01 christophe:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Christophe Raffalli wrote: > > I spend one complete day to adapt Phox (my theorem prover) to 3.08 > because the new = does not check first physical equality. Hopefully, the > backtracking ocamldebugger let me pin point the many "=" which were > looping, otherwise I would have spend a month !!! > > I was assuming two things about equal: > - scan of block from left to right > - a test on adress equality on pointer before follwing the pointer > (which is now wrong in 3.08). > > Then in a data type with some structure starting with an identifier > filed like > > type symbol = structh { id : int; ... }, > > if you have the property that two structures with the same id are always > physically equal, the old "=" would never scan the structure itself. IMHO it is often better to define your own equality predicates because "=" has another annoying property : it fails when comparing "external" objects and this failure happens only when comparison reaches those objects (note that the type system is perfectly happy, even in the presence of "external" objects). For instance, imagine one of the fields of a record you want to compare is a Big_int : your program will fail only if "=" can't decide for inequality before reaching those fields. Objective Caml version 3.08.1 # #load "nums.cma";; # type test = { n: Num.num };; type test = { n : Num.num; } # { n = Num.num_of_string"10000000000000000000000000000000" } = { n = Num.num_of_string "200000000000000000000000000000000" };; Exception: Invalid_argument "equal: abstract value". I discovered this behavior when I was developping libraries to handle DAGs for a symbolic manipulation program written in OCaml (using the Num library). All the preliminary tests of the libraries were OK (I only used "internal" objects) but the day I had to use them I had a great surprise : they were not as "generic" as I believed them to be. In conclusion, if you want your modules to be truly generic, never use "polymorphic" equality. Cheers, Sébastien. ------------------- 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