If one has a class proposal with the prerequisite examples and grammar 
specification, how does one propose this with a possible goal of an alternate 
strawman? 


On May 23, 2011, at 11:25 AM, Bob Nystrom <[email protected]> wrote:

> 
> 
> On Mon, May 23, 2011 at 10:41 AM, Brendan Eich <[email protected]> wrote:
> On May 23, 2011, at 10:03 AM, Alex Russell wrote:
> 
> >> (A) the boilerplate needed to set up a sub-prototype object with correct 
> >> constructor property, and
> >>
> >> (B) the pain of doing correct super calls by hand.
> >
> > I hope we can add the hazards of incorrectly adding mutable state to a 
> > prototype and not an instance to this list. I.e., many people get this 
> > wrong:
> >
> > function C(){
> >  // should include:
> >  //   this._list = [];
> > }
> > C.prototype = {
> >  _list: [],
> >  addToList: function(item) {
> >    this._list.push(item);    // logic error!
> >    // side-effects here
> >  }
> > };
> 
> There's two bugs there:
> 1. Not creating this._list in the ctor.
> 2. Creating one on .prototype.
> 
> If bug #1 is fixed, there's no sensible reason to ever define _list on the 
> prototype since it would always be shadowed.
>  
> > Where and how does the current proposal address (C)?
> 
> One thing I'd like the proposal to support, which it doesn't currently, is 
> initializers on instance property declarations. Then you could do:
> 
> class C {
>   public _list = [];
> }
> 
> With that, you'll correctly get a new _list on each instance of C when it's 
> created.
> 
> - bob
> 
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to