[Haskell-cafe] pointer equality
Brandon Allbery
allbery.b at gmail.com
Thu Jul 21 07:38:20 CEST 2011
On Wed, Jul 20, 2011 at 23:53, Richard O'Keefe <ok at cs.otago.ac.nz> wrote:
> On 21/07/2011, at 9:08 AM, Paul Johnson wrote:
> > I would have thought that the compiler, as a matter of optimisation,
> could insert a check to see if (==) is comparing an object with itself. The
> only way I can see this breaking is with perverse instances of Eq that would
> return False for "f == f".
>
> Presumably inside the body of f, x and x would be
> identical pointers, but the only right answer is False,
> not True.
>
> If you think this is a bit far fetched,
> consider the IEEE definition of equality for
> floating-point numbers:
>
> let x = 0.0/0.0 in x == x
>
> The answer is False, so the optimisation breaks down even
> with a system-defined type.
Also, NaNs are never equal to each other. Also consider SQL's NULL
(relevant if you use Takusen, I suspect).
--
brandon s allbery allbery.b at gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110721/e5ffab32/attachment.htm>
More information about the Haskell-Cafe
mailing list