caitpotter88 at gmail.com
Wed Sep 7 16:43:22 UTC 2016
> On Sep 6, 2016, at 4:10 PM, Domenic Denicola <d at domenic.me> wrote:
> Reflect is a namespace that contains the proxy traps (it’s a bit of an unfortunate name), so we shouldn’t be adding things to it that are not part of the meta-object protocol.
I generally disagree with the idea that this doesn’t belong in “Reflect” because it’s not an MOP operation. There are three reasons for this.
1) only spec editors care about whether an operation is MOP or not. JS authors are concerned with operations and algorithms that are helpful to their work, not whether it’s written as [[Op]]() vs Op(). To a JS author, HasOwnProperty() is just as valid of a reflection mechanism as [[HasProperty]]().
2) Given what was said above about hasOwn() being a valid and useful reflection mechanism, and as you’ve mentioned, the “Reflect” namespace indicates that it performs reflection tasks, not that it lets you perform spec internal MOP operations.
3) Even if Reflect were exclusively for MOP operations, it tends to add extra steps which are not part of the MOP operation. These can make the methods more useful for JS consumers, or they can be convenience mechanisms, but either way, it’s not a 1:1 mapping to MOP operations.
I think it belongs in Reflect, as it’s a reflection capability, the MOP status is a moot point (and it’s just a thin wrapper around [[GetOwnProperty]] anyways), and changing Reflect is less likely to break content than changing Object.
In the meantime, `var hasOwn = Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty)` will continue to be a useful workaround for people.
> A new namespace, or using Object, might be OK. I think that it will still be controversial, since this proposal is in support of an objects-as-maps programming style which has caused many problems in the past and should not be encouraged. See e.g. http://www.2ality.com/2012/11/proto-breaks-webapps.html.
> If you are using objects-as-maps safely, you’d use Object.create(null), in which case the `in` operator works fine and there's no need for hasOwnProperty incantations.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
More information about the es-discuss