Re: More Finaliser Trouble

Ashley Yakeley <[email protected]>
Newsgroups gmane.comp.lang.haskell.ffi
Organization Myself
Message-ID <[email protected]>
In article <[email protected]>,
 Fergus Henderson <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.