wakey wakey!
Marcin 'Qrczak' Kowalczyk
mk167280 at students.mimuw.edu.pl
Fri Oct 27 06:14:14 EDT 2000
On Fri, 27 Oct 2000, Manuel M. T. Chakravarty wrote:
> - So, it is decided to nuke AddrOff?
I would do it.
> - mallocArray/mallocBytes Versus mallocElems: Isn't
> mallocBytes redundant? mallocArray on Word8 should be the
> same, shouldn't it?
IMHO it is better to be able to write
ptr <- mallocBytes (#const sizeof (struct foo))
than
ptr' <- mallocArray (#const sizeof (struct foo))
let ptr = castPtr (ptr' :: Ptr Word8)
when the type involved has nothing common with Word8.
> - Why call it `ptrPlusBytes' when there is no other
> `ptrPlus'? (I could imagine one, which adds multiples of
> the size of the `a' in `Ptr a'.)
There is one in qforeign:
indexPtr :: Storable a => Ptr a -> Int -> Ptr a
ptrPlusBytes is the low level system-dependent primitive.
indexPtr is in the system-independent part. Most user code will use
indexPtr, but there are uses for ptrPlusBytes too:
ptr `ptrPlusBytes` (#const offsetof (struct foo, field_bar))
> - Would `freeHaskellFunPtr' replace
> `IOExts.freeHaskellFunctionPtr'?
I would do so (i.e. deprecate Addr functions).
Or maybe call it freeHsFunPtr; "Hs" is used in some other places.
--
Marcin 'Qrczak' Kowalczyk
More information about the FFI
mailing list