As a functional language, the vanilla OCaml only provides curried calling convention, BuckleScript employs fairly advanced optimizations for curried calling convention, however, the most efficient code is efficient code not relying on optimizations.
Since this release, we provide first class uncurried calling convention, all toolchains provided by BuckleScript can understand uncurried calling convention
let f g x = g x [@bs] // (1)
-
f
is curried function,g
is uncurrid function due to[@bs]
annotation
bsc.exe -i test.ml # infer the type
val f : ('a -> 'b [@bs]) -> 'a -> 'b // (1)
-
g
is inferred as uncurried function'a → 'b [@bs]
whilef
is curried function
function f (g,x){ // (1)
return g (x) // (2)
}
-
f
is optimized and flattened -
g
works like uncurried function
Now ocamldoc
can understand [@bs]
natively(instead of printing a desugared output), we provide an API documentation for the library shipped with BuckleScript, we plan to ship the documentation generator in next release.
See Catch exception
See bs.open
See build schema
See json payload