in reply to Magic::Attach & Co-routines?
in thread RFC Magic::Attach

Anyone see a flaw or potential snags with this attack?

Co-routines that call co-routines are where it gets tricky for the algorithm you outlined. Consider this line in your example:

yield { $self->{left}->next_inorder } if $self->{left};

next_inorder is called recursively, and the context of yielding a yielded result should leave the execution within the recursive call to next_inorder.

You could make this example work by differentiating between a yielded result and a normal return. However, once you have code that has side effects it starts getting hard.