Usage of compare with functionnal values
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
Hello, I've found a difference between the functions compare and (=) with lazy values. Image this definition : let foo = Lazy.from_fun Random.bits;; let bar = Lazy.from_fun Random.bits;; Testing the equality raises an exeption : foo = bar;; Exception: Invalid_argument "equal: functional value". Where comparaison returns 0 : compare foo bar;; - : int = 0 (of course, everithing becomes right once the values has been forced : # foo = bar;; - : bool = false # compare foo bar;; - : int = -1 ) The documentation says that comparing two functionnals values *may* raise an exception, but I'm surprised with the result in this case. Is that expected ? Thanks for your answers Sébastien Dailly