Throwing StopIteration in array extras to stop the iteration

Brendan Eich brendan at
Tue Mar 5 08:37:04 PST 2013

David Bruant wrote:
> I'm happy of the outcome of the thread if .findIndex is introduced, 
> but I can't help wondering whether a new method is going to be 
> introduced every single time someone brings up a pattern that would 
> make good use of stopping an interation early.

Lacking an iteration protocol, that's the natural tendency, although 
there are only so many methods and method-variations likely to be needed.

With for-of, stopping early is done by a break in the body.

Inventing synonyms for exceptions (endframe) or adding escape 
continuations for more locally structured control effects could be done, 
but why? I think we're nearly "done" (no pun!).


More information about the es-discuss mailing list