iterate and enumerate trap signature inconsistency

Tom Van Cutsem tomvc.be at gmail.com
Tue Sep 11 12:37:57 PDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120911/4dde9761/attachment-0001.html>


More information about the es-discuss mailing list