github at esdiscuss.org (2013-07-12T02:27:36.808Z)
Just for the record:
Prototype lookup in ClassDefinitionEvaluation changed in draft rev. 14.,
so an API function should rather look like:
```js
Mixin = (base, ...mixins) => mixins.reduce(Object.mixin, class extendsbase {}.prototype).constructor
```
At least users now no longer need to access .prototype manually:
```
js> class Foo { where(){ return "Foo" } }
js> const BarMixin = { where(){ return "BarMixin" } }
js> (new class extends Mixin(Foo) {}).where()
"Foo"
js> (new class extends Mixin(Foo, BarMixin) {}).where()
"BarMixin"
```
Just for the record: Prototype lookup in ClassDefinitionEvaluation changed in draft rev. 14., so an API function should rather look like: Mixin = (base, ...mixins) => mixins.reduce(Object.mixin, class extends base {}.prototype).constructor At least users now no longer need to access .prototype manually: js> class Foo { where(){ return "Foo" } } js> const BarMixin = { where(){ return "BarMixin" } } js> (new class extends Mixin(Foo) {}).where() "Foo" js> (new class extends Mixin(Foo, BarMixin) {}).where() "BarMixin" - André > A tempest in a teapot. We can have better APIs that look nice for this > use-case. Develop some! > > But let's not rush them into ES6, or invent custom syntax where API is > enough. > > If someone does fast and good work, there's still time for ES6, or 7 > (doesn't matter as much as the quality of the work; browsers are > prototyping parts of both). > > /be > > Dmitry Soshnikov wrote: > >/ > />/ On Jun 11, 2013, at 8:07 PM, Andrea Giammarchi wrote: > />/ > />>/ if it's about being mature, then this is mature enough, if > />>/ Object.mixin will be finalized: > />>/ > />>/ ```javascript > />>/ class Bar extends [M1, M2, M3].reduce( > />>/ Object.mixin, > />>/ Object.create(Foo.prototype) > />>/ ) { > />>/ // class definition ... > />>/ } > />>/ ``` > />>/ > />>/ I must admit that looks weird though ... > />>/ > />/ > />/ Exactly - it might be really cool from the language abilities > />/ perspective, but from the end-users, the example is not that useful: > />/ if the language provides some abstraction (the "class" abstraction in > />/ this particular case), the users which will join to JS starting form > />/ ES6 will have complete right to not even know what that magic > />/ "prototype" mean -- the one which you expose outside actually breaking > />/ the class abstraction. The prototype chain is just the implementation > />/ detail now (and all implementation detail should be hidden in the > />/ best), not a feature. > />/ > />/ P.S.: and I still need to choose my English words better :) for the > />/ mature I probably more meant "syntactically solid" rather than a > />/ library method. > />/ > />/ But yeah, I promised not to do big off-topic in this for-of thread. > />/ > />/ Dmitry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130612/a62e0bfa/attachment-0001.html>