[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Minimal example of extending Guile with Rust?
From: |
Olivier Dion |
Subject: |
Re: Minimal example of extending Guile with Rust? |
Date: |
Mon, 29 Jan 2024 10:33:35 -0500 |
On Mon, 29 Jan 2024, "Dr. Arne Babenhauserheide" <arne_bab@web.de> wrote:
[...]
> Ideally with a fast Scheme-to-Rust-to-Scheme interface (similar to the
> native C arrays numpy exposes to C that allow getting the speed of C).
See <https://doc.rust-lang.org/nomicon/ffi.html>. There is many path to
do this. The main issue is the calling convention.
Rust functions that you want binding for must follow the C calling
convention by using `extern "C"'. Otherwise, the calling convention of
the compiler is used (AFAIK, Rust does not define a calling convention).
You can then simply use the system foreign interface as usual as if the
Rust functions were C functions.
There are others thing to consider. Structures in Rust must have the
attribute `#[repr(C)]' to follow the C ABI for structure members layout.
Otherwise, the compiler is free to re-order members.
Then there is callbacks .. and other things ..
The above link gives comments on all of this but not much details.
Hope that helps.
--
Olivier Dion
oldiob.dev