Closed tizoc closed 3 years ago
@zshipko I'm making some big changes to the calling convention here, but the result will be a far simpler model that will not require macros to call OCaml functions (which are required for handling all the lifetime-related dance). I don't think it should have much impact on how ocaml-derive handles exported functions.
tl;dr is that now every Rust function exposed to OCaml receives rooted (&OCamlRooted<T>
) arguments, and every function imported from OCaml will have to be called with rooted arguments too. For the time being this sill probably incur a small overhead, but if the OCaml runtime/compiler adds support for this calling convention, that should go away.
Another change is that exceptions will not be converted into Err
s anymore, but instead panic by default. I have to figure out an abstraction that lets the user handle these exceptions when required. The idea here is that the OCaml-side should present any failure situation by returning Result.t
values instead of raising exceptions, and any exception that is raised from the OCaml-side will be considered as unexpected.
Changes
&OCamlRooted<T>
parameters.to_rust(cr)
method toOCamlRooted<T>
values.ToRust
trait and implementedto_rust()
directly intoOCaml<T>
.keep_from_raw
method to root values, an unsafe version ofkeep_raw
that returns anOCamlRooted<T>
instead of anOCamlRawRooted
.Continued in #17