On Fri, Apr 6, 2012 at 1:42 PM, Brendan Eich <[email protected]> wrote:
> Axel Rauschmayer wrote:
>
>> Multiple inheritance is where things become interesting. In order to
>> implement some kind of mixin or trait mechanism for JavaScript, you would
>> need the ability to copy private members.
>>
>
> Which .{ can do. The argument is that this is safe against unintended name
> leaks because while the LHS (mixin-derived) is an expression, the RHS
> (mixin-base) is a literal.
>
> Is having only the literal-RHS-only special form too restrictive? It could
> be wrapped in an API usable from downrev script, but this means
> implementors of mixins must use ES6 even though consumers can use pre-ES6.
I feel like I'm probably not the first to suggest this, but what about a
spread operator for objects?
foo.{ ...myMixin }
It would not only work for something like this, but also in regular object
literals to mixin.
let foo = { a:1, b:2, ...myMixin}
And would result in copying all of the properties from myMixin into the
object literal.
- Russ
>
>
> /be
>
> ______________________________**_________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss