Version française
Home     About     Download     Resources     Contact us    
Browse thread
Comparing two things of any two types, in pure OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Diego Olivier Fernandez Pons <Diego.FERNANDEZ_PONS@e...>
Subject: Improper generic equality in Caml (Rossberg's SML vs Caml)
    Bonjour,

What does Andreas Rossberg in his SML vs. Caml page

    http://www.ps.uni-sb.de/~rossberg/SMLvsOcaml.html

mean when he says that

   [Caml] Does not have a proper generic equality
   on one hand (1, r) != (1, r), on the other (1, r) = (1, ref 1)


Is this the "problem" he is pointing  ?

# let r = ref 1 in (1, r) = (1, r);;
- : bool = true

# let r = ref 1 in (1, r) != (1, r);;
- : bool = true

As far as I understand the only dark corners with structural equality are
border cases (Nan) where compare differs from (=).

[from Pervasives.ml]
external (=) : 'a -> 'a -> bool = "%equal"
external (<>) : 'a -> 'a -> bool = "%notequal"
external compare: 'a -> 'a -> int = "%compare"

external (==) : 'a -> 'a -> bool = "%eq"
external (!=) : 'a -> 'a -> bool = "%noteq"

        Diego Olivier