On Wed, May 18, 2011 at 4:10 PM, Bob Nystrom <[email protected]> wrote:
> On Wed, May 18, 2011 at 11:48 AM, Brendan Eich <[email protected]> > wrote: > >> The whole of class declaration is a mouthful. 'function' and 'prototype' >> are overlong too. >> > > Sure. I'm not stuck on "new", but in the chunks of sample code I've put > together using "constructor" (which is what Traceur uses/did use for a good > while) it did actually stick out as a syntactic wart, at least to me. > > Same with 'constructor', and that property must exist somehow. Why not be >> explicit and avoid having two names for one prototype property? >> >> 3 is false in ES5. Reserved identifiers are valid property names. This is >> implemented in all the ES5-supporting browsers. >> > > Ah, my mistake. These are both fair points. It's too bad "constructor" is > such a long word. > > Nowadays most libraries that implement some sort of class wrapping use lengthy names for the constructor and it's not that bad. Mootools var Cat = new Class({ initialize: function(name){ this.name = name; } }); Prototype var Cat = Class.create({ initialize: function(name){ this.name = name; } }); Dojo var Cat = dojo.declare(null, { constructor: function(name){ this.name = name; } }); YUI var Cat = Y.Base.create('cat', null, [], { initializer: function(name){ this.name = name; } });
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

