Hi,

In the latest spec draft, the [[Enumerate]] internal operation has an
"includePrototype" argument (it also has an "onlyEnumerable" argument, but
that's irrelevant to my point). for..in loops use [[Enumerate]]
with includePrototype true and Object.keys/getOwnPropertyNames use
[[Enumerate]] with includePrototype false.
It looks a bit backwards to me. What about the following:
1) [[Enumerate]] only deals with own properties (and doesn't need
the "includePrototype" argument any longer). Arguably the operation can
renamed "[[getOwnKeys]]" or the like
2) for..in climbs the prototype chain itself and uses the own version of
property names enumeration on each object of the prototype chain
3) Object.keys/getOwnPropertyNames just use [[Enumerate]]

If the internal [[Enumerate]] only deals with own properties, it seems that
the enumerate trap can be removed and for..in loop can use the keys and
getPrototypeOf traps instead (as it does with regular objects which was my
point 2).

Even if not adopting the changes I just suggested, it seems that we need
some harmonization between the proxy traps and the internal [[Enumerate]]
signatures.

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

Reply via email to