Extended Object Literals to review

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Mar 14 08:43:48 PDT 2011


On Mar 13, 2011, at 2:16 PM, Brendan Eich wrote:

> ...
> Allen, did you want 'constructor' to be in the class prototype?

Absolutely. Here is what the proposal says

 The value a class initialiser is a new function object. It has a “prototype” property whose value is also a new object. For brevity, the rest of this proposal will use the term “constructor” to refer to the the function object created by such a declaration and the term “prototype” to refer to the object that is created as the value of the function’s “prototype” property. The prototype has a property named “constructor” whose value is the constructor. Both the prototype property and the constructor property have the attributes {writable: false, enumerable: false, configurable: false}. The only real variance from a function expression is the that these properties are non-configurable and that the “prototype attribute is not writable.

Rationale : {writable: false, enumerable: false, configurable: false} is the attribute settings used for built-in “prototype” properties. The same attributes are used for “constructor” as a reflection of the declarative manner in which it was constructed. Class initialiser establish immutable relationships between a constructor and it prototype. If mutable relationships are needed, existing ECMAScript constructs and conventions should be used to define such objects. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110314/1c79c34f/attachment.html>


More information about the es-discuss mailing list