5 ms·
Something slightly more than extern C would be nice, such as definitive way to use Option/Result/Enum across the C boundary
by boredatoms 1y ago
Something slightly more than extern C would be nice, such as definitive way to use Option/Result/Enum across the C boundary
- eptcyka 1y agoWould you want to define that boundary in a way that still maintains compatibility with C? Or would all other languages be expected to link in a Rust library to then do the "extern C" conversion from a rust native type to something that is FFI stable? Swift can do this because Apple will tell you to use Swift or GTFO. Windows has COM. Rust is an orphan without a Primary Platform™ pushing for it, even if the rust language team came up with a technical solution, be it an IDL or a stable ABI with bend-over-backwards run-time linking magic, it would only be useful for other Rust binaries or it would be just as limited as the lingua franca of ABIs - C.
- ronsor 1y agoThe way C3[0] handles this is fairly interesting. An function returning an optional in C3, such as: fn int? run_operation_by_id(int id); Would be equivalent to the following in C: /* ABI type definitions omitted for brevity */ c3fault_t run_operation_by_id(int *return_value, int id); [0] https://c3-lang.org https://c3-lang.org
- deleted 1y ago[deleted]