Allen Wirfs-Brock (2014-07-23T21:03:42.000Z)
On Jul 23, 2014, at 12:54 PM, Brendan Eich wrote:

> Allen Wirfs-Brock wrote:
>> Also, I find some of these questions seem simpler to reason about I think in terms of an iterator with 'next', 'throw' and 'return' methods rather than a generator and its various internal states.
> 
> The loop forms are "external iteration" (http://esdiscuss.org/topic/generators-vs-foreach) and any throw or return within the body should not propagate a useful value to the generator implementation of the iterator (if any). The contract is based only on .next().
> 
> Reifying control effects as exceptions or implicitly invoked methods needs a strong rationale. Implicit is worse than explicit. Now is not the time to invent without extant use cases.

I agree, for-of shouldn't do implicit throws() to its iterator, just return().  However yield* has been specified for a long time to implicitly propagate a throw() to the outer generator into as a throw() to the inner iterator.  Maybe that made sense in the absence of return() but now that we have return ().  yield* is really just a loop that the throw() is terminating early.  From that perspective it seens we should invoke return() and not throw on the inner iterator.

allen
domenic at domenicdenicola.com (2014-07-31T18:31:31.155Z)
I agree, for-of shouldn't do implicit throws() to its iterator, just return().  However yield\* has been specified for a long time to implicitly propagate a throw() to the outer generator into as a throw() to the inner iterator.  Maybe that made sense in the absence of return() but now that we have return ().  yield\* is really just a loop that the throw() is terminating early.  From that perspective it seens we should invoke return() and not throw on the inner iterator.