English version
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.

Browse thread
equality operators in OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-07-25 (20:55)
From: Matthew William Cox <matt@m...>
Subject: Re: [Caml-list] equality operators in OCaml
On Thu, Jul 24, 2008 at 09:40:36PM -0400, Peng Zang wrote:
> Yeah, that always seemed broken to me.  If two things are physically equal 
> (they occupy the same memory space) it doesn't make sense for them to be 
> structurally unequal (contain different content).  Personally, one of the 
> first things I did is redefined (=) to fix this.

It's not broken at all, but complient with a common and longstanding
idiom (at least amoung scientists working with numerical codes.) The way
we test for NaN is by comparing to itself, eg:

    if x = x then (* x is a number *) else (* x is NaN *)