The enumerate() trap predates the TC39 blessing of iterators, but IIRC we did agree to revisit its signature once iterators were in. I think having the enumerate() trap return an iterator is perfectly sensible. There's a catch, however:
As currently specified, direct proxies enforce that the enumerate() trap doesn't return duplicate property names. Now, as Allen hints at, we could make the proxy return its own outer iterator that exhausts the inner iterator returned by the enumerate() trap to insert extra checks. But for the proxy to check for duplicates, it must remember all property names previously produced by the inner iterator. So the main benefit of using an iterator, namely that the entire collection of generated values doesn't need to be retained in memory, seems lost. Cheers, Tom
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

