New Harmony built-in native objects APIs
On Aug 12, 2010, at 2:07 PM, Erik Arvidsson wrote:
It seems like ES5 does not define the [[Enumerable]], [[Configurable]] nor [[Writable]] for the fields on Array.prototype and others like it.
It does, by specifying default values in the intro to Clause 15, last paragraph:
In every case, the length property of a built-in Function object described in this clause has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. Every other property described in this clause has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
ES1-3 did likewise, IIRC.
I spec'ed the attributes for all the methods to match ES+Reality. This means that the methods have {enumerable: false, configurable: true, writable: true}. This matches what JSC, V8, SpiderMonkey and IE9p4 do.
ES5 has your back ;-).
In the future, it would be good if we could follow the existing semantics for the built-in natives.
Agreed.
On Thu, Aug 12, 2010 at 14:44, Brendan Eich <brendan at mozilla.com> wrote:
On Aug 12, 2010, at 2:07 PM, Erik Arvidsson wrote:
It seems like ES5 does not define the [[Enumerable]], [[Configurable]] nor [[Writable]] for the fields on Array.prototype and others like it.
It does, by specifying default values in the intro to Clause 15, last paragraph:
In every case, the length property of a built-in Function object described in this clause has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. Every other property described in this clause has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
Great. Thanks for finding that part.
We are starting to define some new built-in native objects for Harmony. These include, but are not limited to WeakMap, Map and Set. I just went through the wiki and fixed these 3 so that they behave more like the built-in native objects in ES5.
I made changes so that the following works as expected:
var m = new Map; assertTrue(m instanceof Map); assertTrue(Map.prototype.set instanceof Function); assertTrue(Map.prototype.get instanceof Function); assertTrue(Map.prototype.delete instanceof Function);
It seems like ES5 does not define the [[Enumerable]], [[Configurable]] nor [[Writable]] for the fields on Array.prototype and others like it. I spec'ed the attributes for all the methods to match ES+Reality. This means that the methods have {enumerable: false, configurable: true, writable: true}. This matches what JSC, V8, SpiderMonkey and IE9p4 do.
In the future, it would be good if we could follow the existing semantics for the built-in natives.