Open leostera opened 3 years ago
Current workaround is to make a new .ml file with the name of the module you want, and make it include only externals.
(* file: rand.ml *)
external uniform : unit -> float = ""
external uniform_with_ceiling : int -> int = "uniform"
Generates no .erl file ✅ but when called as Rand.uniform ()
translates to rand:uniform()
.
Example:
let run () = Rand.uniform ()
run() -> rand:uniform().
When writing FFIs, regardless of the structure of the code on the Caramel side, we want all of it to go away.
I'd like FFIs to be cheap, so I can throw an
external
pretty much anywhere and be able to call that function.Here's some examples that are inconsistent right now. The first external is the only one that behaves correctly I think:
Generates the following Erlang:
Whereas what I'd expect is:
NOTE: I'd expect this to work only because we have no structure within the symbol name string.
I think we need to do some refactoring in the compiler to make it easier to understand what's happening with the FFIs, so we can guarantee a more uniform behavior.