Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreign pointer primitive type #131

Open
Z-snails opened this issue Jan 15, 2022 · 5 comments
Open

Foreign pointer primitive type #131

Z-snails opened this issue Jan 15, 2022 · 5 comments

Comments

@Z-snails
Copy link
Contributor

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.

@csabahruska
Copy link
Member

What operations do you need?

@luc-tielen
Copy link
Contributor

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.

@Z-snails
Copy link
Contributor Author

@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.

@csabahruska
Copy link
Member

Would foreign pointers interact with the garbage collector?

@Z-snails
Copy link
Contributor Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants