Hello,

The FFI currently provides..

 withArray :: Storable a => [a] -> (Ptr a -> IO b) -> IO b

I think..

 withArrayLength :: Storable a => [a] -> (Ptr a -> Int -> IO b) -> IO b

would be useful because you often need the length in a foreign function
and I guess withArray must pre-calculate the length before allocating
storage in any case (or at least must know the length by the time
marshalling is finished).

It seems a pity to waste time calculating it twice.

Actually, looking at the ffi again I see there is something similar
for CStrings already, but not for arrays in general. Is this an
oversight or a deliberate decision?

Regards
--
Adrian Hey
  


_______________________________________________
FFI mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/ffi

Reply via email to