StopIteration, ForwardToTarget, ... & symbols

Brendan Eich brendan at mozilla.org
Tue Nov 27 17:59:55 PST 2012


Allen Wirfs-Brock wrote:
> On Nov 27, 2012, at 12:45 AM, Brendan Eich wrote:
>
>> This smells pretty bad compared to the PEP-380 style alternative, which cleanly localizes the result to e.value.
>>
> It's always bothered me that there is do direct linkage between between a generator instance that might throw a StopIteration and the actual StopIteration value that is thrown.

This is a non-issue, in JS1.7+ and Python 2.5+. Again, if for-of is 
driving the iteration, there's no need. If a task.js-like scheduler is 
doing it, then it needs to keep book or take care.


> So here is a new idea.  Why not throw the iterator/generator instance it self as the "stop iteration" exception instance.

No, that's ambiguous when the generator wants to throw its 
generator-iterator, and a capability leak in general. The 
generator-iterator is a capability, it should not be thrown willy-nilly 
to unknown catchers.

The championed proposal, based on the Pythonic design _sans_ gratuitous 
GeneratorExit, is at least as well time-tested as other things we're 
incorporating into ES6. I don't think we should fool with it at this 
late stage.

/be


More information about the es-discuss mailing list