Allen Wirfs-Brock (2014-07-23T17:52:07.000Z)
domenic at domenicdenicola.com (2014-07-31T18:26:51.746Z)
Well, in ES6 we don't define iterator termination in terms of a `StopIteration` exception. However, both gen.throw and gen.return are specified in terms of abnormal completion of a yield: - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator.prototype.return - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator.prototype.throw so they both unwind in a similar manner. consider: ```js function gen() { try { while (true) { try {yield foo() } catch (e) { console.log("throw"); throw (e); }; } } finally { console.log("unwind"); }; } var g = gen(); g.next(); g.throw(new Error); //logs: throw, unwind var h = gen(); h.next(); h.return(); //logs: unwind ``` Now that we have return() it isn't clear to me that we actually need throw() or whether for-of/yield* should call throw() like they currently do. This is something I hope to discuss at the upcoming TC39 meeting.