[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Matt Harren <matth@c...> |
| Subject: | [Caml-list] equality testing in 3.08 |
Hi,
I recently upgraded to OCaml 3.08, and ran into problems with the
changed implementation of structural equality. To support NaN, the (=)
operator no longer checks for physical equality or its operands. This
causes two problems:
1) Our application runs 9% slower because comparison isn't as
efficient. When x == y, checking "x = y" takes time proportional to the
size of the structure, instead of constant time.
2) We've been cheating and using (=) on structures that may be cyclic.
This works fine on earlier versions of ocaml, because the structures
contain a unique identifier as their first field. But now that
structural equality checks no longer begin with a physical equality
check, we can get an infinite loop.
To work around this, I've been defining
let (=) x1 x2 : bool =
(compare x1 x2) = 0
at the start of each file, since the "compare" function still starts
with a physical equality check. Is there a better way to override a
definition in the Pervasives module?
Also, has there been any discussion of restoring the old meaning of (=)?
I know it breaks NaN, but the performance difference might make this
worthwhile, even if you have no sympathy for those of us who use = on
cyclic structures. :)
Thanks,
Matt
-------------------
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