Do we really need the [[HasOwnProperty]] internal method and hasOwn trap
allen at wirfs-brock.com
Mon Nov 12 10:17:06 PST 2012
On Nov 12, 2012, at 2:21 AM, Brandon Benvie wrote:
> Shouldn't it be the reverse, based on the removal of getPropertyDescriptor/Names? The proxy controls what i's [[Prototype]] is which indirectly directs how non-own lookups proceed. The functionality of `has` can (and usually should) be derived from proto-walking hasOwn until true or null.
yes, that would be a good fix for this particular problem. [[HasOwnProperty]] could remain as an internal method and HasProperty could be defined as an abstraction operation that uses the [[Prototype]] internal accessor and [[HasOwnProperty]].
Another potential consistency issue is between [[HasOwnProperty]] and [[GetOwnProperty]]. That could be eliminated by combining them into one operation:
[[GetOwnPropety]](name, descriptorNeeded) -> descriptor | boolean | undefined
If descriptorNeeded is true it acts as the current [[GetOwnProperty]]. If descriptorNeeded is false it acts as the current [[HasOwnProperty]].
At the handler-level it makes it impossible to override "hasOwn"without also overriding "getOwnPropertyDescriptor"
More information about the es-discuss