I don't see any risk around mixins for the following reasons:

   1. mixins are nowhere in specs so any solution is personal/ad-hoc but ...
   2. if you use `Object.assign` you don't do that at class definition
   time, you do that eventually after. This possibility will be unchanged, you
   can still attach whatever you want as enumerable property to the class
   prototype once defined ... the idea here is not to not make that possible
   anymore, rather to have a default definition that is configurable but not
   enumerable (+ writable for methods and values or get/set for get/setters)
   3. using literals to define traits is still the easiest way to go and it
   also define a clear line between a class and a trait. Once ES7 will have
   traits syntax within the class one we can assume traits are imported during
   class definition and, as such, will be assigned non enumerable. This would
   still be the least surprise in my opinion


Moreover, using Object.assign for mixins is already a very poor pattern
'cause also getters and setters will be lost during the procedure, adding
an extra surprise in the middle.

Object.assign is good to extend own properties and copy options and
defatuls values, promoting or using it to define the future of traits in JS
... well, I'd personally wouldn't go for it and think about better
solutions for ES7

Meanwhile, we should be careful to base the present (ES6) and the future
based on what we used to do in ES3, hence a window to improve classses.

Best Regards



On Wed, Dec 24, 2014 at 7:02 PM, Kevin Smith <zenpars...@gmail.com> wrote:

> ```js
>> class List extends Array {
>>    itsGoingToBeEnumerable() {
>>      return 'but does it have to and would you expect to?';
>>    }
>> }
>> ```
>>
>
> That's a good point.
>
> As far as I can tell, the downside risk associated with making class
> methods non-enumerable centers around mixins:
>
> - Legacy mixin utilities will tend to fail when given ES6 classes.
> - We have no built-in function for doing proper mixins yet, and
> `Object.assign` won't work at all.
>
> I looked through my ES6 code and found a place where I was using
> `Object.assign` as an simplistic mixin function.  It might be a pain to
> have to import a userland utility for such cases.
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to