Browse thread
RE: [Caml-list] Are you sure the new "=" of 3.08 is good ?
- Harrison, John R
[
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: | Harrison, John R <johnh@i...> |
| Subject: | RE: [Caml-list] Are you sure the new "=" of 3.08 is good ? |
| As I said in an earlier post, you can do | | let (=?) x y = (Pervasives.compare x y = 0) | | and use =? instead of = in places where you need the "early stop" | behaviour. OK. I wanted to be sure this was a recommended solution, not just something that happens to work at the moment. | Of course, if the speed of equality is critical, you can also define | your own comparison functions for the types of interest, or even (as | Damien suggested) implement hash-consing. In fact, the key function is an alpha-conversion test on name-carrying lambda-terms. Since it's almost always expected to succeed with full equality after a shallow comparison, I now do an equality test first to get the early-out behaviour. I can just change it to put an "==" into the main recursion when it hasn't gone through any lambdas. John. ------------------- 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