caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] equality testing in 3.08
@ 2004-08-02  1:54 Matt Harren
  2004-08-02  9:50 ` Christophe TROESTLER
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Harren @ 2004-08-02  1:54 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-02 11:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-02  1:54 [Caml-list] equality testing in 3.08 Matt Harren
2004-08-02  9:50 ` Christophe TROESTLER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).