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 XAA15331; Thu, 7 Oct 2004 23:14:16 +0200 (MET DST) 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 XAA14901 for ; Thu, 7 Oct 2004 23:14:15 +0200 (MET DST) Received: from smtp.cegetel.net (mf00.sitadelle.com [212.94.174.77]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i97LEFWE007072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 7 Oct 2004 23:14:15 +0200 Received: from univ-savoie.fr (80-125-224-27.dti.cegetel.net [80.125.224.27]) by smtp.cegetel.net (Postfix) with ESMTP id 87240671C0; Thu, 7 Oct 2004 23:14:14 +0200 (CEST) Message-ID: <4165B1A5.9040208@univ-savoie.fr> Date: Thu, 07 Oct 2004 23:14:13 +0200 From: Christophe Raffalli User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list Subject: [Caml-list] Are you sure the new "=" of 3.08 is good ? X-Enigmail-Version: 0.83.3.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 4165B1A7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; raffalli:01 raffalli:01 univ-savoie:01 phox:01 prover:01 follwing:01 cyclic:01 speedup:01 assertion:01 floats:01 idem:01 savoie:01 chablais:01 73376:01 univ-savoie: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 !!! 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. The new "=" can dramatically change the complexity of a program using such a structure. It can even loop if your data type are cyclic but all cycle need to traverse a structure with the above property (in this case the old "=" did not loop). I imagine there are other examples where the old "=" can be much faster than the new one. 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 Clearly for most ocaml programmer the old "=" was better. Moreover, code relying on, nan = nan to give false are very suspicious to me !!! If you need to debug, you have better to insert assertion about your floats. Finally, the IEEE norm about floating point arithmetic is not perfect yet. For instance it makes nothing about transcendentals function (see below) so I really do not think this norm is so good that OCaml MUST respect it for polymorphic equality (a new better norm may appear one day). -- Here are two small problems with the actual implementation of float: asin 1.000001 gives nan while some floating point expression which you can mathematically prove to be in [-1, 1] gets computed as 1 + epsilon ! so asin x should be equal to asin 1 if x > 1 (idem for -1) otherwise all call to asin shoud do a comparison with 1 and -1 sin x with x > 10e100 gives a value which is certainly wrong since you can not compute the modulo 2 pi for such a big number. sin x should give nan when |x| is too big. -- Christophe Raffalli Université de Savoie Batiment Le Chablais, bureau 21 73376 Le Bourget-du-Lac Cedex tél: (33) 4 79 75 81 03 fax: (33) 4 79 75 87 42 mail: Christophe.Raffalli@univ-savoie.fr www: http://www.lama.univ-savoie.fr/~RAFFALLI --------------------------------------------- IMPORTANT: this mail is signed using PGP/MIME At least Enigmail/Mozilla, mutt or evolution can check this signature --------------------------------------------- ------------------- 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