Open Z-snails opened 2 years ago
What operations do you need?
If there's only support for foreign pointers, that makes code-gen easier as the layout is consistent, however having structs would be useful, eg for interfacing with pass-by-value C libraries.
Idiomatic C never passes a struct by value in one of the arguments, only by pointer to avoid copies.
@csabahruska Passing too and from FFI functions. My current use case is arbitrary precision integers in the idris2-grin backend.
@luc-tielen unfortunately not all C libraries are idiomatic.
Would foreign pointers interact with the garbage collector?
In the long term, yes (eg for IORef
) however I don't think for Integer
all that is needed is a static (as in known at runtime) finaliser function (which can also be grin which calls the ffi free
function)
This is needed for various features of many functional languages, eg arbitrary precision integers and arrays implemented in FFI.
If there's only support for foreign pointers, that makes code-gen easier as the layout is consistent, however having structs would be useful, eg for interfacing with pass-by-value C libraries.