Classes: suggestions for improvement

Brendan Eich brendan at mozilla.com
Sun Jun 12 22:49:42 PDT 2011


On Jun 12, 2011, at 8:46 PM, Axel Rauschmayer wrote:

> I’ve only got one use case for this, but “class methods” would also work better if they could be attached to the prototype (and subject to inheritance) instead of the constructor.

We had a thread about this, because Ruby and CoffeeScript (which translates to JS and copies properties to do "constructor inheritance") both support class method inheritance.

Putting class methods on the prototype mixes up is-a relations, making the class constructor delegate to the class prototype. That breaks constructor is-a function in general. Better to have two parallel proto-chains, one from subclass prototype to superclass prototype, the other from subclass constructor to superclass constructor.

/be


More information about the es-discuss mailing list