Alastair Reid wrote:
However we don't really need to discuss this anyway, since I don't think either runAtomically or atomicallyModifyIORef need to be in the FFI standard. I'm quite happy to leave this open.
As usual, I disagree. I think the FFI spec would be incomplete if it provided Haskell finalizers but no mechanism to write them safely.
Since we've talked about mutable state quite a lot, my suggestion would be that we write, in addition to the FFI specification, a Mutable State specification which documented newIORef, readIORef, writeIORef, atomicModifyIORef (and possibly, for reasons of efficiency, atomicModifyIORef_). I don't think it need be very long. It wouldn't have to be frozen right away; it would be good if some other working group could be formed to carry it further, so that for example it could also include mutable arrays.