[Haskell-cafe] pointer equality

Paul Johnson paul at cogito.org.uk
Wed Jul 20 23:08:43 CEST 2011


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".

Paul.

On 07/20/2011 04:51 AM, Nikhil A. Patil wrote:
> Hi,
>
> Is there any way of getting the following code to immediately return
> True without performing the element-by-element comparison? Essentially
> this boils down to checking whether pointers are equal before
> comparing the contents.
>
>> main = print $ f == f
>>       where f = [1..10^9]
> Thanks!!
>
> nikhil
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe




More information about the Haskell-Cafe mailing list