Usage of compare with functionnal values

"Sébastien Dailly [email protected] [ocaml_beginners]" <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.