Let's get this finished
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Sat Jan 6 08:02:06 EST 2001
Sat, 06 Jan 2001 21:58:26 +1100, Manuel M. T. Chakravarty <chak at cse.unsw.edu.au> pisze:
> > type CString = Ptr CChar
> > type CStringLen = (CString, Int)
> Hmmm, yes, although pointer/length pairs are not very common
> in C and this module is a language dependent module (and so
> should be called `MarshalCString').
I added the explicit-length variants when I needed them for the Python
interface, after I realized that it's not possible to express them
with variants which always stoped on input '\0' and didn't mark the
output length besides writing a '\0'. The '\0' variants are now small
wrappers around the explicit-length variants.
> But SimonM said that he doesn't want to make errno Haskell thread
It would force wrapping every C function which may set errno in another
C function which returns the error in a thred-safe way. The wrapper
would have to check for errno and pass it in some way to Haskell
together with the proper result - either through a pointer (which needs
extra alloca per C function call) or special thread-local variables.
It would be really bad to not have thread-local errno.
> > withObject :: Storable a => a -> (Ptr a -> IO b) -> IO b
> BTW, can't we just use `with' now. IIRC, the only reason Marcin
> used `withObject' was because of a clash with the implicit parameter
> This has been changed now, hasn't it?
Everybody agreed that "let" should be used instead of "with",
but the change has not been made yet.
> There is one exception: MarshalCString shouldn't be
> re-exported by Foreign (like CTypes).
If language separation is realistic, we would also keep errno handling
outside basic Foreign. But it yields several separate C-specific modules...
It would reexport Foreign, CTypes, CTypesISO, MarshalCString and CErrors
(or whatever they will be called).
BTW, why are CTypes and CTypesISO separate?
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
^^ SYGNATURA ZASTÊPCZA
More information about the FFI