unsafePtrEq in 5.03?
conal at microsoft.com
Thu Apr 18 10:37:33 EDT 2002
I'm using unsafePtrEq for a fast equality check, followed by a derived
structural equality check. Here's the code:
-- Equality test that first tries cheap pointer-equality
(==%) :: Exp -> Exp -> Bool
x ==% y = (x `unsafePtrEq` y) || x == y
Sigbjorn gave me this replacement:
unsafePtrEq :: a -> a -> Bool
unsafePtrEq a b = (unsafeCoerce# a) `eqAddr#` (unsafeCoerce# b)
which is fine by me.
From: Simon Marlow
Sent: Thursday, April 18, 2002 4:29 AM
To: Sigbjorn Finne; Conal Elliott
Subject: RE: unsafePtrEq in 5.03?
Could you remind us what you're using unsafePtrEq for? Perhaps there's
another way to do what you want, or we could maybe reinstate
> -----Original Message-----
> From: Sigbjorn Finne [mailto:sof at galois.com]
> Sent: 17 April 2002 04:09
> To: Conal Elliott
> Cc: Ghc-Bugs
> Subject: Re: unsafePtrEq in 5.03?
> A spot of CVS archeology revealed that it was removed as
> a primop as part of a NCG overhaul couple of months ago.
> Don't know if leaving it out was simply an omission or
> if there's something deeper going on.
> Anyway, you can approximate the old defn with the following:
> module PtrEq where
> import GHC.Base
> unsafePtrEq :: a -> a -> Bool
> unsafePtrEq a b = (unsafeCoerce# a) `eqAddr#` (unsafeCoerce# b)
> Clearly, it doesn't chase indirections.
> ----- Original Message -----
> From: Conal Elliott
> To: Ghc-Bugs
> Sent: Tuesday, April 16, 2002 18:43
> Subject: unsafePtrEq in 5.03?
> Did unsafePtrEq disappear between 5.02 and 5.03? - Conal
> Glasgow-haskell-bugs mailing list
> Glasgow-haskell-bugs at haskell.org
More information about the Glasgow-haskell-bugs