External
external
,或叫 “FFI”(foreign function interface),或者更简单叫做 “interop” (interoperability 的缩写),帮助 Reason 与其他语言交流,像 C 和 JavaScript。
想象一个 let 绑定,省略实体,但是标注了类型(强制)声明。
external myCFunction: int => string = "theCFunction";
Note: external
s can only be at the top level, or inside a module definition. You can't declare them in e.g. a function body.
用法
You'd use an external value/function as if it was a normal let binding.
For more infos on how to link up your C functions within your Reason application, have a look at the Dealing with foreign libraries section in the dune
build system docs.