From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Christophe Raffalli <christophe.raffalli@univ-savoie.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Are you sure the new "=" of 3.08 is good ?
Date: Fri, 8 Oct 2004 17:54:36 +0200 [thread overview]
Message-ID: <20041008155436.GA20780@yquem.inria.fr> (raw)
In-Reply-To: <4165B1A5.9040208@univ-savoie.fr>
> 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
next prev parent reply other threads:[~2004-10-08 15:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-07 21:14 Christophe Raffalli
2004-10-08 7:38 ` Jean-Christophe Filliatre
2004-10-08 8:31 ` Christophe Raffalli
2004-10-08 15:10 ` Damien Doligez
2004-10-08 9:37 ` Sébastien Furic
2004-10-08 15:54 ` Xavier Leroy [this message]
2004-10-08 2:54 Harrison, John R
2004-10-08 5:49 ` Christophe Raffalli
2004-10-08 6:54 ` David Brown
2004-10-08 16:25 Harrison, John R
2004-10-08 16:35 Harrison, John R
2004-10-08 17:34 ` Damien Doligez
2004-10-09 8:58 ` Xavier Leroy
2004-10-09 17:56 Harrison, John R
2004-10-09 18:10 Harrison, John R
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041008155436.GA20780@yquem.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=christophe.raffalli@univ-savoie.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox