Open stuhlmueller opened 9 years ago
One possible complication is that ES6 syntax may not play nicely with our sweet.js integration.
sweet.js is refactoring on Babel. https://github.com/mozilla/sweet.js/pull/485
We can independently discuss whether to enable ES6 for the implementation and for webppl programs. (As I understand it, both are blocked right now by incompatibility with the sweet.js
readableNames
option.) If we enable ES6 for webppl programs, we could consider enforcing that all variables are declared as constants (e.g., const x = 1
). This would make it more explicit that they can't be mutated (and are block-scoped, unlike var
), and would move webppl closer to being a true subset of Javascript.
As I understand it, both are blocked right now by incompatibility with the sweet.js readableNames option.
In general I think that's right, since once we have HMC (#81) we'll be expanding macros in both.
I like the const
idea. I tried it in a webppl program and surprisingly it seems to work already. It looks like it's because like var
, const
is parsed as a VariableDeclaration
(but with its type
field set to const
), so while not officially supported things just happen to work out. Of course, relying on an accidental feature to stick around probably isn't a great idea, so waiting for full ES6 support seems sensible.
Node already supports many ES6 features. If we add babelify to our browserify transform, we can start using these features in our code. I've been using ES6 for another project and I think it allows for significantly more readable code in some situations.
ESLint (#225) is compatible with ES6 (using babel-eslint).