Compiler ยท Oct 7, 2017

Announcing BuckleScript 1.7.0

Hongbo Zhang
Compiler Team

New Release

We are excited to announce bs-platform@1.7.0, which highlights following new features and changes:

First class uncurried calling convention

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

Curried calling convention

Let's show the feature with an example file called test.ml:

ML
let f g x = g x [@bs]

or in Reason

RE
let f = (g, x) => g(. x);

f is curried function, g is an uncurried function due to [@bs] annotation. In Reason, the dot in g(. x) is equivalent to [@bs].

When we evaluate the program with the bsc command...

SH
bsc.exe -i test.ml # infer the type

...we will get following inferred interface:

ML
val f : ('a -> 'b [@bs]) -> 'a -> 'b // <1>

or in Reason

let f: ((. 'a) => 'b, 'a) => 'b

As you can see in the examples above, g is inferred as an uncurried function ((. 'a) => 'b) while f is still a curried function.

The compiler will also yield following JS output:

JS
function f (g,x){ return g (x) }

Again, the code shows that...

  • f is optimized and flattened

  • g works like uncurried function

API documentation

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.

More Interop including Js.Promise.t

Unicode string and interpolation support

See String interpolation

Catch exceptions raised on JS side

See Catch exception

Mixed data source

See bs.open

ES6 support in Safari

See fix es6 support in browser

bs-dev-dependencies support in the build system

See build schema

bs.as accept json literal support

This feature is mentioned in the Functions / Fixed Arguments section.

Bug fixes, performance improvement, and stress tests

[#1549](Notable bug fixes https://github.com/bucklescript/bucklescript/issues/1549), #1539, #1520

This article was originally released on https://bucklescript.github.io/blog/2017/10/07/release-1-7-0
Want to read more?
Back to Overview