From: tad.hosford@... Date: 2016-01-29T21:30:58+00:00 Subject: [ruby-core:73588] [Ruby trunk - Bug #12036] [Open] Enumerator's automatic rewind behavior Issue #12036 has been reported by Ryan Hosford. ---------------------------------------- Bug #12036: Enumerator's automatic rewind behavior https://bugs.ruby-lang.org/issues/12036 * Author: Ryan Hosford * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- When enumerating an enumerator, the enumerator automatically rewinds when #next raises an error. The concern here is that someone may need to handle that error and continue processing the rest of the enumerator. 12:22 < Ox0dea> I think tjohnson found where the StopIteration was being raised? 12:23 < tjohnson> A friend in #projecthydra pointed me here: https://github.com/ruby/ruby/blob/trunk/enumerator.c#L655-L660 12:24 < tjohnson> seems quite deliberate. compare: https://github.com/ruby/ruby/blob/trunk/enumerator.c#L925-L930 12:25 < Ox0dea> Yeah, Line 651 in there is the one birthing the new Fiber, and since dead ones don't maintain context, the surrounding Enumerator can't pick up where it left off. **12:26 < Ox0dea> It's almost certainly intentional, and most likely even The Right Thing, but "make easy things easy and hard things *possible*".** tjohnson first demonstrated the behavior in a gist: https://gist.github.com/no-reply/4b38f26b3fe32ad266a7#gistcomment-1683794 lucasb also produced a snippet that clearly demonstrates the behavior: https://eval.in/509874 Thanks: 0x0dea, lucasb, tjohnson, rthbound -- https://bugs.ruby-lang.org/ Unsubscribe: