[−][src]Macro ocaml_interop::ocaml_call
Calls an OCaml function
The called function must be declared with ocaml!
. This macro can
only be used inside ocaml_frame!
blocks, and the frame GC
handle must be passed as the first argument to the function.
The result is either Ok(result)
or Err(ocaml_exception)
if
an exception is raised by the OCaml function.
Examples
ocaml! { fn print_endline(s: String); } // ...somewhere else inside a function ocaml_frame!(gc, { let ocaml_string = to_ocaml!(gc, "hello OCaml!"); ocaml_call!(print_endline(gc, ocaml_string)).unwrap(); });