On 10/28/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > On Sun, Oct 28, 2007 at 01:43:07PM -0700, Don Stewart wrote: > > stefanor: > > > IO blocks unboxing in GHC. How fast is your mock-C code refactored to > > > do IO outside of the loops only? > > > > It doesn't! The above code yields: > > > > Main.$wloop :: GHC.Prim.Int# > > -> GHC.Prim.State# GHC.Prim.RealWorld > > -> (# GHC.Prim.State# GHC.Prim.RealWorld, () #) > > > > $wgo_rMK :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -> > > GHC.Prim.Int# > > where > > $s$wgo_rMI :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# > > Ah, interesting. I was reading something too general from > http://hackage.haskell.org/trac/ghc/ticket/1592#comment:5. >
Right, unboxing is successful here because the arguments are marked as strict with (!) annotations. The IO hack described in that bug report would only be a problem if the arguments were not marked strict, and were used in code that has to be executed after an IO call. Although I don't think all of the strictness annotations are even necessary here. In any case, loop must evaluate i before the call to print; there would only be an issue if it called an IO function before doing anything that demands i. Cheers, Tim -- Tim Chevalier * catamorphism.org * Often in error, never in doubt "Accordingly, computer scientists commonly choose models which have bottoms, but prefer them topless." -- Davey & Priestley, _Introduction to Lattices and Order_ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe