Andrea Giammarchi (2015-02-12T20:30:44.000Z)
You are also probably forgetting class methods are non enumerable, and
assign works only with enumerable and it copies/assigns retrieved values,
not descriptors.

Please let's drop `Object.assign` from the traits discussion already, since
it won't work with any ES5+ feature, thanks.

On Thu, Feb 12, 2015 at 9:19 PM, Benjamin Gruenbaum <inglor at gmail.com>
wrote:

> Sorry, forgot to CC the list
>
> *From:* Benjamin Gruenbaum <inglor at gmail.com>
> *Date:* February 12, 2015 at 22:19:14 GMT+2
> *To:* Domenic Denicola <d at domenic.me>
> *Subject:* *Re: about lightweight traits*
>
> Those points are good, let me try to address them
>
> State - In other languages like C# and swift the issue with adding custom
> state can be indeed very painful - in JS we can add a symbol on the object
> mixed into or lazily creating it when the method first executes with a
> default value. A Symbol can be used for separation of state from the object
> if that is desired. I don't understand the argument about internal state -
> how would a mixin be aware of a class's internal not relating to it state
> anyway?
>
> Protocol - I agree here, but can't you call `.assign` in the constructor?
>
> On Feb 12, 2015, at 22:11, Domenic Denicola <d at domenic.me> wrote:
>
>
> From: es-discuss [mailto:es-discuss-bounces at mozilla.org
> <es-discuss-bounces at mozilla.org>] On Behalf Of Benjamin Gruenbaum
>
>
> We have `Object.assign` that works fantastically for most classic trait
> use cases.
>
>
> Well, actually, it works extremely poorly. The old (now dead or deferred)
> `Object.mixin`, once called `Object.define`, is a better fit. But it still
> fails to account for a couple things, off the top of my head:
>
>
> - Being able to add custom initialization logic to the class constructor
> when "mixing in" a trait. You can construct a custom protocol around this,
> but (a) that means the class you're mixing in to needs to be aware of the
> protocol; (b) everyone needs to agree on a protocol across the ecosystem.
>
> - Pretty much anything to do with private state doesn't work anymore.
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150212/d710a0d6/attachment-0001.html>
d at domenic.me (2015-02-17T20:25:29.899Z)
You are also probably forgetting class methods are non enumerable, and
assign works only with enumerable and it copies/assigns retrieved values,
not descriptors.

Please let's drop `Object.assign` from the traits discussion already, since
it won't work with any ES5+ feature, thanks.