Allen Wirfs-Brock (2014-09-10T19:20:59.000Z)
domenic at domenicdenicola.com (2014-09-17T22:02:55.567Z)
On Sep 10, 2014, at 10:58 AM, Boris Zbarsky wrote: > Now in this self-hosted case, how do I express IteratorClose? why wouldn't a self-hoster just continue with: ```js for (let next of iter} { /* body */ } ``` which will do all the IteratorClose work for them. In fact, isn't that how we want a self-hoster to code it. Anything either ES or WebIDL does that is hostile to that pattern is counter productive as self-hosters are probably going to do that anyway, even if the semantics is a slight mismatch to the spec. > Seems to me like it's just a matter of wrapping the relevant bits (which ones, though? whatever constitutes the loop "body" > ) in a try/catch and doing this in the catch clause: > > ```js > catch (e) { > if ("return" in iter) { > iter.return(); > } > throw e; > } > ``` > > That ought to match the semantics of IteratorClose, yes? You also will need a finally clause, if the loop body contains any explicit returns.