Compiler ยท Nov 28, 2019

What's new in BuckleScript v7 (Part 2)

Hongbo Zhang
Compiler Team

New dev Release

The second dev release 7.0.0-dev.2 is released for testing!

As we mentioned in the previous post, we compile records into js objects in this release. This makes the generated code more idiomatic, however, this is not enough to write idiomatic bindings to manipulate arbitrary js objects, since the key of js objects can be arbitrary which is not expressible in ReasonML syntax, so we support user level customization now, which makes idiomatic bindings really easy.

type entry = { [ "EXACT_MAPPING_TO_JS_LABEL"] x: int, [ "EXACT_2"] y: int, z: obj, } and obj = { [ "hello"] hi: int, }; let f4 = ({x, y, z: {hi}}) => (x + y + hi) * 2;
function f4(param) { return (((param.EXACT_MAPPING_TO_JS_LABEL + param.EXACT_2 | 0) + param.z.hello | 0) << 1); }

As you can see, you can manipulate js objects using Reason pattern match syntax, the generated code is highly efficient, more importantly, bindings to JS will be significantly simplifie.

Happy Hacking.

Want to read more?
Back to Overview