You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
yorickpeterse opened this issue
Feb 17, 2024
· 1 comment
Assignees
Labels
compilerChanges related to the compilerfeatureNew things to add to Inko, such as a new standard library moduleruntimeChanges related to the Rust-based runtime library
Certain C libraries rely on the use of callback functions, such as GUIs or cURL. We should support passing references to module methods for such cases, allowing the use of these libraries from Inko.
To enable this, we extend the fn extern syntax to allow for bodies like so:
fn extern example_method(value: Int) -> Int {
value
}
Here fn extern means that the function (explicitly) uses the C calling convention/ABI, not the Inko ABI. Name mangling is still applied nor will we offer a way to opt out, as Inko isn't meant to be used for writing a .so or .a library linked into other projects. Just as extern methods without a body, these methods can't be generic.
To pass a reference to the method, one uses mut example_method (note the lack of arguments), just as how pointers to C values are created using mut expr.
compilerChanges related to the compilerfeatureNew things to add to Inko, such as a new standard library moduleruntimeChanges related to the Rust-based runtime library
Description
Certain C libraries rely on the use of callback functions, such as GUIs or cURL. We should support passing references to module methods for such cases, allowing the use of these libraries from Inko.
To enable this, we extend the
fn extern
syntax to allow for bodies like so:Here
fn extern
means that the function (explicitly) uses the C calling convention/ABI, not the Inko ABI. Name mangling is still applied nor will we offer a way to opt out, as Inko isn't meant to be used for writing a.so
or.a
library linked into other projects. Just asextern
methods without a body, these methods can't be generic.To pass a reference to the method, one uses
mut example_method
(note the lack of arguments), just as how pointers to C values are created usingmut expr
.Blocked by
Related work
No response
The text was updated successfully, but these errors were encountered: