Object.mixin, why just for enumerables (?)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Object.mixin, why just for enumerables (?)

medikoo
Object.mixin, why just for enumerables (?)

This is related to: http://mozilla.6506.n7.nabble.com/Object-define-Object-mixin-tp265638p265651.html

In a spec we have both Object.assign and Object.mixin.

Object.assign is for copying properties ES3 way, which even in ES5 world is what you want in most cases (btw. I don't agree with http://www.nczonline.net/blog/2012/12/11/are-your-mixins-ecmascript-5-compatible/ For 3 years I work strictly with ES5, and I never had a case in which I wanted to just copy enumerables and preserve getters, it's highly unwanted in all cases I had).

Object.mixin is for copying definitions, which I find as rare but also valid use case, e.g. to mimic multiple inheritance by copying properties from one prototype to other. However this cannot work as intended if it's limited just for enumerables. All properties in native prototypes are already defined as not enumerable, and this is also what I follow in my code when I define models.

So as specified currently I find Object.mixin as a function that I don't find valid use case for, and I strongly miss something like Object.assignDefinitions, which will copy properties by descriptors, no matter whether they're enumerable or not.

/Mariusz
Reply | Threaded
Open this post in threaded view
|

Re: Object.mixin, why just for enumerables (?)

André Bargull-2
> Object.mixin, why just for enumerables (?)

It's a copy-paste error in the draft:
https://bugs.ecmascript.org/show_bug.cgi?id=1999#c1


>
> This is related to:
> http://mozilla.6506.n7.nabble.com/Object-define-Object-mixin-tp265638p265651.html
>
> In a spec we have both Object.assign and Object.mixin.
>
> Object.assign is for copying properties ES3 way, which even in ES5 world is
> what you want in most cases (btw. I don't agree with
> http://www.nczonline.net/blog/2012/12/11/are-your-mixins-ecmascript-5-compatible/
> For 3 years I work strictly with ES5, and I never had a case in which I
> wanted to just copy enumerables and preserve getters, it's highly unwanted
> in all cases I had).
>
> Object.mixin is for copying definitions, which I find as rare but also valid
> use case, e.g. to mimic multiple inheritance by copying properties from one
> prototype to other. However this cannot work as intended if it's limited
> just for enumerables. All properties in native prototypes are already
> defined as not enumerable, and this is also what I follow in my code when I
> define models.
>
> So as specified currently I find Object.mixin as a function that I don't
> find valid use case for, and I strongly miss something like
> Object.assignDefinitions, which will copy properties by descriptors, no
> matter whether they're enumerable or not.
>
> /Mariusz
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Object.mixin, why just for enumerables (?)

medikoo
> It's a copy-paste error in the draft:
> https://bugs.ecmascript.org/show_bug.cgi?id=1999#c1

Great news. Thanks!

Sorry for noise.

/Mariusz
Reply | Threaded
Open this post in threaded view
|

Re: Object.mixin, why just for enumerables (?)

Andrea Giammarchi-2
this is the closest to specs we have today:

it does copy all own descriptors so it's suitable for almost everything you need but `Symbols` (in any case absent in ES5)

That being said, it will be compatible with my `Symbol` proposal/shim/polyfill if used.

But I am not testing, neither suggesting, to use the latter one if not truly needed and not through `Object.mixin`


br


On Thu, Oct 3, 2013 at 6:29 AM, medikoo <[hidden email]> wrote:
> It's a copy-paste error in the draft:
> https://bugs.ecmascript.org/show_bug.cgi?id=1999#c1

Great news. Thanks!

Sorry for noise.

/Mariusz



--
View this message in context: http://mozilla.6506.n7.nabble.com/Object-mixin-why-just-for-enumerables-tp293611p293623.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Object.mixin, why just for enumerables (?)

Allen Wirfs-Brock
In reply to this post by medikoo
No, the closest yo a spec that we have is the spec

http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.mixin

Andrea Giammarchi <[hidden email]> wrote:

this is the closest to specs we have today:

it does copy all own descriptors so it's suitable for almost everything you need but `Symbols` (in any case absent in ES5)

That being said, it will be compatible with my `Symbol` proposal/shim/polyfill if used.

But I am not testing, neither suggesting, to use the latter one if not truly needed and not through `Object.mixin`


br


On Thu, Oct 3, 2013 at 6:29 AM, medikoo <[hidden email]> wrote:
> It's a copy-paste error in the draft:
> https://bugs.ecmascript.org/show_bug.cgi?id=1999#c1

Great news. Thanks!

Sorry for noise.

/Mariusz



--
View this message in context: http://mozilla.6506.n7.nabble.com/Object-mixin-why-just-for-enumerables-tp293611p293623.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Object.mixin, why just for enumerables (?)

Andrea Giammarchi-2
I was talking about concrete and usable implementation of those specs. Updates and contribution always welcome, of course.


On Thu, Oct 3, 2013 at 11:18 AM, Allen Wirfs-Brock <[hidden email]> wrote:
No, the closest yo a spec that we have is the spec

http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.mixin

Andrea Giammarchi <[hidden email]> wrote:

this is the closest to specs we have today:

it does copy all own descriptors so it's suitable for almost everything you need but `Symbols` (in any case absent in ES5)

That being said, it will be compatible with my `Symbol` proposal/shim/polyfill if used.

But I am not testing, neither suggesting, to use the latter one if not truly needed and not through `Object.mixin`


br


On Thu, Oct 3, 2013 at 6:29 AM, medikoo <[hidden email]> wrote:
> It's a copy-paste error in the draft:
> https://bugs.ecmascript.org/show_bug.cgi?id=1999#c1

Great news. Thanks!

Sorry for noise.

/Mariusz



--
View this message in context: http://mozilla.6506.n7.nabble.com/Object-mixin-why-just-for-enumerables-tp293611p293623.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



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