On May 19, 2011, at 2:10 PM, Mark S. Miller wrote:

> On May 19, 2011 3:09 PM, "Bob Nystrom" <[email protected]> wrote:
> >> class Point {
> >>   constructor(this.x = 0, this.y = 0) {
> >>   }
> >>  ...
> >> }
> >
> >
> > Yeah, that's in the document the proposal is linking to now 
> > (https://docs.google.com/document/d/1gOFRSBOKtB8VjXC5LRhhNiGi1n1QQ6z1O6LyxjrOB3g/edit?hl=en_US).
> >  I'd like to roll that into the proposal as an optional refinement. I 
> > really really like this.
> 
> Please do. I like it too. But yes, as an optional refinement.
> 
+1

And I'm +1 on including it normatively, FWIW.

You guys have been good sports, here is one last minor comment: The 
ExportableDefinition nonterminal produces this right-hand side:
      Identifier = Expression ;                            // provided data
which works perfectly after class (now static, hrm, two minor comments then 
;-). But without a keyword in front,

class Point {
  x = 0;
  ...
}

is a bit of a mystery.

Is it an assignment expression-statement? No, no statements as ClassElements.

Could it be creating a prototype property, as other unprefixed property 
initialisers such as get and set accessor declarations, and property 
initialiser extensions declaring prototype methods, do? Yes, that's the intent.

But, I object (mildly), it does not look like a property initialiser. It looks 
like an assignment expression-statement.

I see the dilemma: if you use colon, you walk into class body as object 
initialiser body, with comma separation, etc. If you use equal sign, you avoid 
that.

But this is only for defining data properties on the class prototype. Is this 
case common? I can't think of a built-in class that has such a data property. 
It's very rare.

So how about YAGNI -- leave this out, it won't be needed enough and one can 
always write C.prototype.x = 0 or Object.defineProperty(C.prototype, 'x', ...) 
after the class declaration has been evaluated.

Or if you have a measured need based on some existing code, which I'd love to 
hear about: consider a prefixing keyword to make this look like an alternative 
to static x = 0.

Ok, second minor point. At least dherman and I really dug the use of class 
where static is now specified. We avoid unwanted baggage from other (and static 
as in typing) languages. We point directly to the value of the binding created 
by the class declaration or evaluated from an anonymous class declaration: the 
constructor.

Any strong reason why this change was made?

Thanks for considering,

/be

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

Reply via email to