2012/9/11 Mark S. Miller <erig...@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
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to