« Return to Thread: Could FFI support pass-by-value of structs?

Could FFI support pass-by-value of structs?

by Maurí­cio :: Rate this Message:

Reply to Author | View in Thread

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

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

 « Return to Thread: Could FFI support pass-by-value of structs?