Re: again: nullForeignPtr

Alastair Reid <[email protected]>
Newsgroups gmane.comp.lang.haskell.ffi
Organization Reid-Hoffmann
Message-ID <[email protected]>
> the discussion on ForeignPtrs without finalizers didn't come to a
> conclusion. I specifically need the nullForeignPtr which was easy enough
> with the FFI of GHC 5.04:
> [...]
> do I have to create a dummy C function?

Yes, create a dummy C function.
(Actually, you could use 'free' since it does nothing if passed NULL.)

--
Alastair

ps Personally, I would use

  Maybe (ForeignPtr a)

in the places where you are currently using a ForeignPtr which could be null 
with 'Just x' being used only when x is not null.

I haven't tried exactly this but I have lots of experience using  Maybe (Ptr 
a) in this way and it works great: Haskell's type system catches errors that 
would be runtime errors in C.
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.