Ptr and ForeignPtr Questions
Thu, 20 Sep 2001 02:38:11 -0700
At 2001-09-20 02:14, Simon Marlow wrote:
>I'll just add that the docs have been updated for 5.02,
Do you have a URL for that?
>And don't forget that using foreignPtrToPtr is quite dangerous; much
>better to use withForeignPtr instead, otherwise you might find the
>ForeignPtr being finalised earlier than you expect.
This is because foreignPtrToPtr is not in the IO monad, correct?
foreignPtrToPtr :: ForeignPtr a -> Ptr a;
A function like this:
ioForeignPtrToPtr :: ForeignPtr a -> IO (Ptr a);
ioForeignPtrToPtr fp = withForeignPtr fp return;
...would surely be safe? The 5.00 documentation claims that it isn't,
however, but I don't see why.
Ashley Yakeley, Seattle WA