More Finaliser Trouble
Ashley Yakeley
ashley at semantic.org
Tue Jul 15 04:04:20 EDT 2003
In article <20030714071832.GA3813 at ceres.cs.mu.oz.au>,
Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > Should there perhaps be something like ...
> >
> > newForeignPtrWithUserData :: Ptr a -> Ptr b -> FunPtr (Ptr a -> Ptr b -> IO
> > ()) -> IO (ForeignPtr a)
> >
> > ... where the second argument is a "userData" pointer that gets passed on
> > to the finalizer?
>
> IMHO yes!
Well now what if you want to pass two extra pointers? It's true you
could "glue" them together, but equally, you can glue together the two
pointers passed to newForeignPtrWithUserData.
Bear in mind that your newForeignPtrWithUserData, "Ptr a" and "Ptr b"
are effectively interchangeable. You have one object, a ForeignPtr, that
holds two pointers. When the ForeignPtr gets finalised, it passes both
pointers to its finaliser function (assuming it has exactly one). There
really isn't a lot of difference between the two of them when there's
only one finaliser.
--
Ashley Yakeley, Seattle WA
More information about the FFI
mailing list