On 6 Nov 2004, at 13:07, Keean Schupke wrote:

Just been reading arround. According to ghc docs, the noinline
pragma is in the Haskell98 report. On that basis what is wrong
with using the following to initialise these top-level constants?

   {-# NOINLINE newref #-}
   newref :: IORef Int
   newref = unsafePerformIO $ newIORef 0


What's wrong is that it isn't haskell. (NOINLINE may be in the haskell report, but unsafePerformIO isn't.. and without unsafe operations, NOINLINE is of course quite safe)


myRef1 = unsafePerformIO $ newIORef 0
myRef2 = unsafePerformIO $ newIORef 0

In a referentially transparent language, these two values myRef1 and myRef2 *must* be the same. That's the whole thrust of referential transparency.


But it is certainly not what the user intends....

Jules

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to