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 RAA23452; Fri, 8 Oct 2004 17:54:38 +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 RAA23429 for ; Fri, 8 Oct 2004 17:54:36 +0200 (MET DST) Received: from yquem.inria.fr (yquem.inria.fr [128.93.8.37]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i98Fsa2E009591; Fri, 8 Oct 2004 17:54:36 +0200 Received: by yquem.inria.fr (Postfix, from userid 18180) id 4A8DABC3F; Fri, 8 Oct 2004 17:54:36 +0200 (CEST) Date: Fri, 8 Oct 2004 17:54:36 +0200 From: Xavier Leroy To: Christophe Raffalli Cc: caml-list Subject: Re: [Caml-list] Are you sure the new "=" of 3.08 is good ? Message-ID: <20041008155436.GA20780@yquem.inria.fr> References: <4165B1A5.9040208@univ-savoie.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4165B1A5.9040208@univ-savoie.fr> User-Agent: Mutt/1.3.28i X-Miltered: at concorde with ID 4166B83C.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 phox:01 prover:01 cyclic:01 cyclic:01 follwing:01 pervasives:01 speedup:01 floats:01 generic:01 floats:01 kahan:01 compiler:01 inconsistent:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > 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 !!! If you get non-termination with the = comparison in 3.08, it means your program is comparing cyclic data structures, which could also have caused looping with the old = comparison. It's just that the new = loops "more easily" than the old one. But I would argue that your original code was living dangerously close to the edge. Don't feel bad: in developing 3.08 we found several instances of misuses of = over cyclic structures (types) in the OCaml compiler... > 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). That was true of the old implementation, but has never been guaranteed. As others mentioned, you can recover the behaviour above in 3.08 (it also works in earlier releases) as follows: let (=?) x y = (Pervasives.compare x y = 0) and use =? instead of = where appropriate. > So the comparison between both "=" gives > > old "=": > - can have much better complexity of some specific data structure > - nan = nan => true > > new "=" > - can have a small linear speedup on some specific data structure > - nan = nan => false > You're missing the essential point: the old "=" was inconsistent over floats, i.e. you'd get different results from the generic = and the type-specialized = over floats. Semantic consistency takes precedence over efficiency. > Finally, the IEEE norm about floating point arithmetic is not perfect > yet. Maybe not, but it's a consensus that took umpteenth years to achieve (and got Kahan a Turing award), so one needs very very strong reasons to depart from it. - Xavier Leroy ------------------- 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