Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Peng Zang <peng.zang@g...>
Subject: Re: [Caml-list] equality operators in OCaml
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Friday 25 July 2008 06:34:54 am Christophe TROESTLER wrote:
> On Thu, 24 Jul 2008 21:40:36 -0400, Peng Zang wrote:
> > On Thursday 24 July 2008 06:32:36 pm Jon Harrop wrote:
> > > There are some complications here. Firstly, NaN has multiple
> > > representations that may or may not be physically equal but is always
> > > structurally unequal to itself.
> >
> > 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.
>
> Humm...  http://citeseer.ist.psu.edu/goldberg91what.html is certainly
> a good read...
>
> My 0.02¤,
> C.

I second that.  Particularly relevant is how there is not one unique NaN but a 
family of them.  OCaml has three treatments for them:

1) (=) treats all NaNs as different (even if they may in fact, at the bit 
level, be the same)

2) (compare) treats all NaNs as the same (even if they may in fact, at the bit 
level be different)

3) (==) two NaNs are equal iff they share the same memory

(2) tends to come up the most often as you typically don't care what kind of 
NaN it is, as long as it is one.

Peng
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)

iD8DBQFIicFAfIRcEFL/JewRAiFkAJ46YFay72ONIDD7qk75/izt9ne8gACgvMzu
EYZkQb7fYAlEU+KXnixp7to=
=5iAB
-----END PGP SIGNATURE-----