I noted some open issues on "Classes with Trait Composition"

Juan Ignacio Dopazo dopazo.juan at gmail.com
Wed May 18 19:32:26 PDT 2011


On Wed, May 18, 2011 at 4:10 PM, Bob Nystrom <rnystrom at google.com> wrote:

> On Wed, May 18, 2011 at 11:48 AM, Brendan Eich <brendan at mozilla.com>
>  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;
    }
});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110518/39cab435/attachment.html>


More information about the es-discuss mailing list