[Haskell-cafe] Top-level TVars

Tomasz Zielonka tomasz.zielonka at gmail.com
Wed Dec 14 15:29:24 EST 2005


On Wed, Dec 14, 2005 at 02:17:17PM -0000, Simon Marlow wrote:
> Suppose you create two top-level IORefs with the same type, like this:
> 
>   var1 = unsafePerformIO $ newIORef 0
>   var2 = unsafePerformIO $ newIORef 0
> 
> GHC's CSE optimisation will common these up - after all, it's the same
> expression, so it must yield the same result, right?

Ah, yes. Thanks for explanation.

> To turn this off, we use -fno-cse.   It's good practice to use -fno-cse
> whenever you use top-level mutable objects of any kind.  You can put it
> in the source file:
> 
> {-# OPTIONS_GHC -fno-cse #-}
> 
> at the top of your file.

How about a new pragma:

{-# OPTIMIZER_HANDS_OFF var1 #-}

;-)

Best regards
Tomasz

-- 
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland


More information about the Haskell-Cafe mailing list