Extended Object Literals to review

Juan Ignacio Dopazo dopazo.juan at gmail.com
Sat Mar 12 06:04:37 PST 2011

Hi! I hope you don't mind a couple of questions about this proposal.

The <superclass> meta property definition says:

This causes the [[Prototype]] value of the new class’ prototype to be set to
> the prototype property value of the designated constructor function

Shouldn't the superclass' prototype be chained with the class' constructor
prototype instead of replacing it, as in Douglas Crockford's prototypal
inheritance article <http://javascript.crockford.com/prototypal.html>? I
believe this is easier to understand and less error prone, because when
modifying properties in the new class prototype they won't be added to the
superclass' prototype.

Why were class bodies chosen as object initializers instead of function
bodies? Function bodies allow for a couple of good concepts such as defining
private variables by default with the var statement, avoiding the use of the
this keyword for private variables and thus producing shorter code when

Also, what happens to methods in these proposal? Are they defined as
properties of the instance or as part of the prototype? If they are fresh
instance properties, is there a method for defining prototype methods when
using the <superclass> meta property?

Thanks! Harmony is looking awesome!


On Wed, Mar 9, 2011 at 11:53 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

> I've updated all of the Harmony extended object literal proposals
> http://wiki.ecmascript.org/doku.php?id=strawman:object_initialiser_extensions based
> upon discussions at the last several TC39 meetings.  In particular a very
> productive informal discussion at the Sept. meeting.
> The major change in this iterations is a new "class" declaration based upon
> object literals. This declaration supports the declarative object definition
> that exactly mirrors the constructor/prototype/instance organization used by
> the EMAScript built-in objects.
> I also did some updates to the Private Names proposal
> http://wiki.ecmascript.org/doku.php?id=strawman:private_names to clarify
> some issues that have come up in previous meetings. There is also a proposal
> for integrating Private Names with the extended object literals.
> These items are on the agenda for the next TC39 meeting but discussion here
> is certainly welcome.
> Allen
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110312/f64cc14e/attachment-0001.html>

More information about the es-discuss mailing list