New: proposal-known-keys

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

New: proposal-known-keys

Ranando King
This proposal adds 7 new static methods to `Object` that add support for dealing with all of the enumerable properties of objects with prototypes.

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

Re: New: proposal-known-keys

Ranando King

On Mon, Nov 26, 2018 at 11:11 PM Ranando King <[hidden email]> wrote:
This proposal adds 7 new static methods to `Object` that add support for dealing with all of the enumerable properties of objects with prototypes.

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

Re: New: proposal-known-keys

T.J. Crowder-2
On Tue, Nov 27, 2018 at 5:14 AM Ranando King
<[hidden email]> wrote:

Do you have any evidence to back up the assertions in the Motivation
section? I haven't seen an issue with people making odd design
decisions "just" to make properties own properties.

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

Re: New: proposal-known-keys

Andrea Giammarchi-2
FWIW I'd change the name to inherited:

 * assignInherited
 * inheritedKeys
 * ...

and I'd probably skip own, at least it's clear the method does something else.

However, it might end up like Object.assign(Object.assignInherited(target, source), source) so that maybe it's better if inherited copies also own properties.



On Tue, Nov 27, 2018 at 8:36 AM T.J. Crowder <[hidden email]> wrote:
On Tue, Nov 27, 2018 at 5:14 AM Ranando King
<[hidden email]> wrote:

Do you have any evidence to back up the assertions in the Motivation
section? I haven't seen an issue with people making odd design
decisions "just" to make properties own properties.

-- T.J. Crowder
_______________________________________________
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: New: proposal-known-keys

Ranando King
> However, it might end up like Object.assign(Object.assignInherited(target, source), source) so that maybe it's better if inherited copies also own properties.

Andrea, that's why I'm using "known". Basically, `if (prop in obj)` and `prop` is enumerable, then it will appear in `Object.knownKeys(obj)`. These modified versions take into account all "known" enumerable keys. I could also see a set of "inherited" functions, but I can't see where they'd have the same utility as "own" and "known".

>  I haven't seen an issue with people making odd design decisions "just" to make properties own properties.

T.J., The limitations of the existing functions are a current and (even in my book) valid argument in favor of the public-fields proposal. But the public-fields proposal introduces a lesser-of-2-evils type problem into the language:
* choose [[Set]] semantics and risk losing some future potential for language expansion
* choose [[Define]] semantics and break inheritance involving accessor properties
* choose both and increase the complexity of the engine, leaving the decision to the developer as per current ES
* choose neither and deal with either the objects-on-prototype foot-gun or developers being too sloppy with `super`

Currently, public-fields is attempting to push through the 2nd option here, despite the damage it will cause. That's an odd design decision, especially considering the 3rd option is superior to the first 2, and the 4th option is even more viable still if the foot-gun is surgically fixed. As you already know, I've got a proposal for that .

On Tue, Nov 27, 2018 at 3:59 AM Andrea Giammarchi <[hidden email]> wrote:
FWIW I'd change the name to inherited:

 * assignInherited
 * inheritedKeys
 * ...

and I'd probably skip own, at least it's clear the method does something else.

However, it might end up like Object.assign(Object.assignInherited(target, source), source) so that maybe it's better if inherited copies also own properties.



On Tue, Nov 27, 2018 at 8:36 AM T.J. Crowder <[hidden email]> wrote:
On Tue, Nov 27, 2018 at 5:14 AM Ranando King
<[hidden email]> wrote:

Do you have any evidence to back up the assertions in the Motivation
section? I haven't seen an issue with people making odd design
decisions "just" to make properties own properties.

-- T.J. Crowder
_______________________________________________
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