My issue with the proposal is that the iterator would be global for
all instances. It would be like each maintaining a single global state,
rather than per-hash.
Ah, but not if you create your iterators as anonymous closures! Then
you can have several instances, each working on separate data, and
each keeping state.
but more to the point, coroutine like behaviour only happens when yield
is used. In the example you present, no yield happens, so it will behave
like any other subroutine
Why do you say that? next_inorder() yeilds.
I was referring to your:
Say I'm iterating over a collection and break out of the loop when I
find the element I want. Just last it, and don't look at the rest.