iterate and enumerate trap signature inconsistency
Tom Van Cutsem
tomvc.be at gmail.com
Tue Sep 11 23:19:46 PDT 2012
2012/9/11 Mark S. Miller <erights at google.com>
> [...]
> If we change this API from returning an array of strings to returning an
> iterator, I agree that alters the balance and justifies waiving this
> particular guarantee.
>
I also don't see any real issues with waiving the duplicate names check.
It's unrelated to the usual non-configurability/non-extensibility
invariants.
Just to spell it out, that would mean that in the following code:
for (var name in obj) { ... }
where obj is either a proxy or an object with a proxy in its prototype
chain, |name| can be bound to the same string multiple times through the
loop.
Note that even if we would waive the duplicate property check, the proxy
still needs to return a wrapped iterator for the enumerate() trap to:
- coerce each produced value to a String
- check whether all non-configurable enumerable properties of the target
have been produced. One way to check this would be to retrieve these
properties in a set before the start of the loop, and remove each
encountered property from the set. If, after the very last loop iteration,
the set is non-empty, the proxy throws a TypeError.
Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120912/8c17117f/attachment.html>
More information about the es-discuss
mailing list