Proposed change to ForeignPtr
Alastair Reid
alastair at reid-consulting-uk.ltd.uk
Thu Aug 8 19:52:02 EDT 2002
Since requiring ForeignPtr.newForeignPtr would require preemptive
concurrency (see previosu discussion), I propose the following changes:
1) Add these functions:
makeForeignPtr :: Ptr a -> FunPtr (Ptr a -> IO ()) -> IO ForeignObj
attachForeignPtrFinalizer :: ForeignPtr a -> FunPtr (Ptr a -> IO ()) -> IO ()
2) Remove newForeignPtr and addForeignPtrFinalizer
Two variants on this proposal:
1) Reuse the old function names instead of inventing new ones.
I don't care much either way.
2) Instead of removing the old functions, rename them and mark them
as an optional extra.
I think this would be a mistake - the GHC documentation is the
right place to mention extensions which are not available on all
ffi implementations.
I have implemented makeForeignPtr in Hugs (I didn't do
attachForeignPtrFinalizer yet because it'll take a bit longer to add
that functionality and we can compile most (all?) of the hierarchial
libs without it.
--
Alastair Reid alastair at reid-consulting-uk.ltd.uk
Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/
More information about the FFI
mailing list