
Hello Chris, Monday, September 22, 2008, 2:48:16 PM, you wrote:
used a very unreliable trick. And the "use castToSTUArray" suggested alternative is a really poor one since I am not using arrays at all.
castToSTUArray does the same as your code, only in ST monad so you can skip unsafePerformIO trick if you dn't know, ST is a subset of IO monad with a limited set of operations guaranteed to not have side-effects. so, cvt x = unsafePerformIO $ do alloca $ \place -> do poke place x peek place and cvt x = runST $ do place <- newArray (0,1) writeArray place 0 x readArray place 0 generates almost the same code (the only difference is kind of memory allocated) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com