I take it that there might not be any standard support for inheritance in 
ES.next beyond what is already there?

My personal favorite would be to get even more into Self-style (or Cecil-style) 
class-less inheritance, but I realize that that’s not for everyone.

Until consensus is reached, how about the following interim solution?

(1) I think what is most needed is standard support for subtyping. Node.js has 
util.inherits(subtype, supertype) (was: sys.inherits) that provides the bare 
minimum. [1] This could be added to ES.next without involving too much baggage.

(2) Defining constructor plus prototype in a single construct is also helpful. 
I really like how Resig’s Simple Inheritance looks (externally ;-), because it 
equates a type with the protoype (=a single object literal) and does not change 
much of JS’s core beyond that.

For the sake of good tool support, some guidance should be given with regard to 
inheritance. The current mess of competing approaches makes comprehensive JS 
tool support almost impossible. I don’t mean dictating something, but maybe 
giving best practices. I don’t think most frameworks need more than (2) (plus 
maybe some kind of transformation that tools would not need to know about for 
syntactic analysis).

[1] http://rentzsch.tumblr.com/post/588755951/using-node-jss-sys-inherits
[2] http://ejohn.org/blog/simple-javascript-inheritance/


As an aside: If only we could transport the elegance of object literals to 
inheritance, somehow. Object.create() feels like a good start. I’ve tried my 
hand at a purely prototypal API, but I find it difficult to make the syntax as 
beautiful as plain object literals.
http://www.2ality.com/2011/01/going-completely-prototypal-in.html

-- 
Dr. Axel Rauschmayer

[email protected]
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to