External
external
,或 "FFI"(外來函式界面),或簡單地 "交互"( 意思是 "交互作用性")是 Reason 如何與其他語言進行溝通,像是 C 或 JavaScript。
Imagine writing a let binding, but with its body omitted and its (mandatory) type written down:
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.