Version française
Home     About     Download     Resources     Contact us    
Browse thread
Equality of functional values
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Tom <tom.primozic@g...>
Subject: Re: [Caml-list] Equality of functional values
>
>  Why not take the suggestion of Gerd Stolpmann and declare
>
>   let ( = ) x y = Pervasives.compare x y = 0
>
> at the beginning of your files ?



Because it fails on functions (if functions are the same, it returns true,
otherwise it raises an exception...

# let f x y = x + y;;
val f : int -> int -> int = <fun>
# compare f f;;
- : int = 0
# compare (f 0) (f 0);;
Exception: Invalid_argument "equal: functional value".