Sep 27 meeting notes

Erik Arvidsson erik.arvidsson at gmail.com
Fri Sep 30 17:11:35 PDT 2011


I believe that we have a solid proposal even without 2 and 5.

2. Ensure the shape of the instance

In most cases this is not an issue. Neither ES5 nor Python seems to
have suffered too bad without this. There are ways to make this less
likely to happen. Always initialize your instance field before calling
anything. Setters on the prototype makes this harder but if you really
want it you can also set things on your prototype.

class C extends B {
  constructor(x, y) {
    this.x = x;
    this.y = y;
    super.constructor();
  },
  x: 0,  // To ensure no setter is invoked on a prototype
  y: 0
}

I know this is pretty painful but I don't consider this to be a show stopper.

5. Allow const properties

I know this tastes pretty salty but here goes

class Point {
  constructor(x, y) {
    Object.defineProperty('x', {value: x});
    Object.defineProperty('y', {value: y});
  }
}


On Fri, Sep 30, 2011 at 16:57, Waldemar Horwat <waldemar at google.com> wrote:
> On 09/30/2011 04:37 PM, Brendan Eich wrote:
>>
>> since we haven't come up with a way to do 2 and 5 that works,
>
> That's what makes this into a dead end.   Worse, by claiming the class
> syntax you'd be precluding finding a different way that works in the future.
>
>    Waldemar
>



-- 
erik


More information about the es-discuss mailing list