On Sep 29, 2011, at 6:20 PM, Brendan Eich wrote:

> On Sep 30, 2011, at 1:11 AM, Erik Arvidsson wrote:
> 
>> On Thu, Sep 29, 2011 at 17:08, Bob Nystrom <[email protected]> wrote:
>>> class Monster {
>>>   constructor(this.name, this.health) {}
> 
> I <3 this. It beats the (public name, public health) variant in my view by 
> being explicit and not dragging in p-words.

I dislike it as it conflates assignment with declaration.

> 
> 
> This is great, and I'm still a sections fan, but they mix badly if there are 
> any hints or smells of object literal data property initialiser synax. You 
> (Bob) dodge that by using let, Oliver used var (and IIRC Bob started with 
> var; so did ES4) -- however, Oliver and ES4 by fiat put data properties on 
> the instance, methods on the prototype.
> 
> Separately, and a while ago, Alex pointed out that mutable prototype data 
> properties, e..g let attackers = []; in this Monster example, are a footgun. 
> People fail to shadow and mutate a shared singleton.
> 
> So why do we need declarative syntax for data properties on the prototype at 
> all? Data properties on prototypes are exceedingly rare and usually a bug.

Agreed.  If anything people want constants on "the class"

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

Reply via email to