Browse thread
equality operators in OCaml
[
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: | 2008-07-25 (22:27) |
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 04:14:22 pm Matthew William Cox wrote: > 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 *) > > Matt Yeah, I just learned that today. But these days, most languages have functions for testing for NaN. OCaml has classify_float for example. Just FYI Peng -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFIilNnfIRcEFL/JewRAiRjAJ9jRQy37/JtI+nZ9fhiInp3HOvKWgCgtmIv k2koED9DunAM73PmaEPhnbg= =SaDz -----END PGP SIGNATURE-----