[Haskell-cafe] Could FFI support pass-by-value of structs?
Maurício
briqueabraque at yahoo.com
Tue Jun 16 09:48:19 EDT 2009
It's not usual, but it is allowed to have values of
structs passed between functions directly instead of
using pointers:
/*****/
struct ex {
int x;
int y;
int z;
};
ex example_functions (ex p)
{
(...)
}
/*****/
Would it be possible to allow that in Haskell FFI
by, say, allowing any instance of Storable to be
used in a 'foreign' declaration? Like:
--
data Ex = (...)
instance Storable Ex where
sizeOf _ = ...
alignment = sizeOf
(...)
foreign import ccall "example_functions" exampleFunction
:: Ex -> IO Ex
--
Thanks,
Maurício
More information about the Haskell-Cafe
mailing list