[
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: | Tom <tom.primozic@g...> |
| Subject: | Re: [Caml-list] Equality of functional values |
I guess the "correct" way to do = equality would be to check for tag (
Obj.tag (Obj.repr x)), and if it isn't float (or float array) then ==
equality would be performed first. The problem is that this would have to be
implemented by the OCaml developers, as the naive implementation:
let equal x y =
if Obj.tag (Obj.repr x) = Obj.double_tag then x = y
else
if x == y then true else x = y
doesn't work, as it should be called recursively (comparing two lists of
functions will fail, because the functions would be compared by =, not by
equal).
Actually, the implementation could be improved further, as it could actually
return true on examples such as
# let f x y = x + y;;
val f : int -> int -> int = <fun>
# f == f;;
- : bool = true
# (f 1) = (f 1);;
- : bool = true
because the parameters, passed to a closure, could be compared, too...
Anyhow, this can be added to the wishlist :)
- Tom