Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] equality testing in 3.08
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <debian00@t...>
Subject: Re: [Caml-list] equality testing in 3.08
On Sun, 1 Aug 2004, "Matt Harren" <matth@cs.berkeley.edu> wrote:
> 
>   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.

I do not know what you are comparing but maybe a custom comparison
function would make things even faster?  As an example,

          min : 'a -> 'a -> 'a
and
          let min' x y = if (x:int) < y then x else y

have (very) different speed characteristics!

>   2) We've been cheating and using (=) on structures that may be cyclic.

Same: why don't you define the meaningful equality?  Sure, you do not
have the convenience of the name "=" but you can use "===", "=^=",
"=~=",...  This probably would also make your software easier to
understand (the "strange" comparison on cyclic structures would be
made explicit).

Regards,
ChriS

-------------------
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