On Monday, 2011-05-23 at 18:14 , Isaac Schlueter wrote: 
> On Mon, May 23, 2011 at 08:51, Brendan Eich <bren...@mozilla.com> wrote:
> > Class syntax is like a lint brush for such features. If we add it, it will 
> > accrete more semantics (with unambiguous syntax, I hope) over time. This is 
> > just inevitable, in my view. It makes me want to resist classes and look at 
> > smaller and more direct fixes for the two known prototypal hazards.
> 
> Yes, please!
> 
> I assume "two known hazards" is referring to your previous email:
> "subclassed prototype/constructor set-up and super calls."
> 
> I've been using this pattern in my OOP javascript programs lately:
> https://github.com/isaacs/inherits/blob/master/inherits.js
> 
> It works really well, behaves as expected (easy for the author to say,
> ha, but it doesn't violate instanceof, doesn't call ctors more than
> once, doesn't clobber already-added prototype properties, etc.) And
> it's about 10 lines, easy to read and grok.
> 
I personally prefer backbone style as IMO it has advantage of keeping complete 
setup in one declaration statement.

> What would make it even nicer, however, with minimal added syntax:
> 
> 1. Call "super(a, b, c)" instead of "Child.super.call(this, a, b, c)"
> 2. Maybe Parent.extend(Child) or Child.inherit(Parent) instead of
> inherits(Child, Parent)
> 3. Right now, calling parent versions of overridden methods is a
> painful: "this.constructor.super.prototype.someMethod.call(this)".
> It'd be nice to use something like "super.someMethod()".
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to