Closed bakkot closed 1 year ago
Why? It should work with Set
-like objects, Set
iterators have no .return
method - this is an extension of iterators protocol not related to this case. However, it's extra work for implementations and extra problems for optimization.
Right now it's an invariant in the specification that every iteration of an iterator will either exhaust the iterator, hit an error condition in the iterator, or close the iterator. I would like to preserve that invariant. I don't think we want to make "does not have a .return
method on its .keys
iterator" part of the definition of "Set
-like objects".
I don't think that such a definition is worse than the overcomplication of this method.
I am pretty strongly on the side of preserving the invariant that the spec closes iterators.
Fixes https://github.com/tc39/proposal-set-methods/issues/81.