Accueil     À propos     Téléchargement     Ressources     Contactez-nous

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2006-09-16 (18:53) From: Diego Olivier Fernandez Pons 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

```