ryani.spam: > > > Your code is broken in a most evil and insidious way. > > > > Interesting. This is for a toy project, so I'm not too > worried, but lets say I wanted to do this "correctly" and I > was set on using IOUArray for some reason. (The Haskell wiki > claims that StorableArray is slower; is that actually the > case?) > > > > Which of the following fixes would work now? Which has the > lowest probability of not working in the future? > > > > 1) Declare f to take Addr# and don't construct a Ptr Word32 > > I suspect this would be enough unless the GC changed to > some sort of continous GC which can happen even without an > allocation > > > > 2) Declare f to take MutableByteArray# > > Is this good enough to make the collector happy? > > > > 3) Something else I haven't thought of? > > If there was no other option, and StorableArray wasn't > slower, and I was working on a real project, I'd probably > wrap my own around ForeignPtr like Data.ByteString.
Yeah, we have ForeignPtr arrays and Foreign.Array /exactly/ for calling to C safely. I don't know why people suggest all these other dodgy solutions, when there's one that's guaranteed by the FFI spec to work. -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe