ECMAScript.next: TC39’s September 2012 meeting
Thanks to
Rick Waldron, we have a
detailed account of the decisions regarding ECMAScript.next that were made by TC39
[1] during its meeting from September 18-20, 2012. This blog post summarizes and explains the highlights.
September 18
Highlights of the
notes:
- The final draft of the Internationalization API (ECMA-402) has been approved (page with PDFs, HTML format). It will be submitted to the Ecma General Assembly for ratification. This API exists separately from ECMAScript and will be available for ECMAScript 5 or later.
- TC39 discussed River Trail [2], JavaScript language extensions for parallel programming. River Trail won’t be in ECMAScript 6, but ECMAScript 7 or later is possible.
-
For a while, operators for batch-assignment and/or batch-definition were considered for inclusion in ECMAScript 6. The latest decision was to instead use a function and to specify the properties to be added via an object literal. This kind of merging of two objects is already popular in third-party libraries. For example, Underscore.js has _.extend. ECMAScript 6 will have the function
Object.assign(target, source)
Another blog post explains how it works.
- Concise method definitions will be enumerable: ECMAScript.next offers a more compact way of defining methods in an object literal:
obj = {
theMethod(x, y) {
return x * y;
}
};
This is equivalent to:
obj = {
theMethod: function (x, y) {
return x * y;
}
};
This kind of concise method definition will be enumerable [5] in ECMAScript.next. Quoting David Herman: “Users expect that things they create to be enumerable and things that the platform provides to be non-enumerable.”
September 19
Highlights of the
notes:
- More work on refining the proxy API.
- Property name objects [6] are now called “symbols”. That’s a good choice. Now you can say: Each property has a name. Such a name is either a string or a symbol.
- Syntactic support for symbols: There are two main pitfalls with symbols. First, they introduce an indirection that is difficult for many people to grasp and leads to verbosity:
let sym = new Symbol();
let obj = {
// computed property name (abandoned feature!):
[sym](x, y) {
...
}
};
console.log(obj[sym](7, 5));
Instead, the following would be easier to understand:
private @sym;
let obj = {
@sym(x, y) {
...
}
};
console.log(obj.@sym(7, 5));
Second, if a an object or a class has many private properties, there is much redundancy, because you always have to declare a symbol before you can use it. The discussion of how to best avoid this redundancy is ongoing.
September 20
Highlights of the
notes:
References
- ECMAScript: ES.next versus ES 6 versus ES Harmony [explains what TC39 is]
- JavaScript: parallel programming via River Trail coming to Firefox
- A closer look at super-references in JavaScript and ECMAScript.next
- Properties in JavaScript: definition versus assignment
- JavaScript properties: inheritance and enumerability
- Private data for objects in JavaScript
- ECMAScript.next: arrow functions and method definitions