ecma262
ecma262 copied to clipboard
Better iterator close
EDIT: this is slightly wrong and will need to be tweaked. Don't review yet.
Fixes #3072.
Open to other names for the new AOs. IteratorCloseSuppressingExceptions would also work.
I didn't add an async version since we only touch async iterators in a couple places.
"abrupt completion" isn't synonymous with "throw completion", so the use in IfAbruptCloseIterator can't be replaced as currently written. As it happens, all of the callsites of IfAbruptCloseIterator currently in the spec can only pass it throw completions or normal completions, so we could change it to "IfThrowCloseIterator" and then change the implementation. But the iterator helpers proposal introduces some uses of IfAbruptCloseIterator which can get passed return completions, so we'd need to do something else there. I'm inclined to leave it alone.
I went a little further than #3072 suggests, in the third commit, which I think ends up in a cleaner place. I'm fine leaving it at the second commit though.
Note that this will require changes in 402, Temporal, and Iterator Helpers (if we include the third commit), which I'll do after we land this.
I don't think you need IteratorCloseForThrow
. Anywhere that says
Perform IteratorCloseForThrow(...)
,
you can just say
Perform IteratorClose(...)
with the same semantics.
I don't think you need
IteratorCloseForThrow
. Anywhere that saysPerform IteratorCloseForThrow(...)
, you can just sayPerform IteratorClose(...)
with the same semantics.
By convention (enforced by ecmarkup) you can't call any completion-returning AO without either explicitly mentioning the fact that it returns a completion record (by wrapping with Completion
) or unwrapping with either ?
or !
.
We could say Perform Completion(IteratorClose(...))
, of course. But that's less clear than an explicit AO, I think.
By convention (enforced by ecmarkup) you can't call any completion-returning AO without either explicitly mentioning the fact that it returns a completion record (by wrapping with
Completion
) or unwrapping with either?
or!
.
Okay.
We could say
Perform Completion(IteratorClose(...))
, of course. But that's less clear than an explicit AO, I think.
I think I'd prefer Perform Completion(IteratorClose(...))
over another AO.