21 Mar
2016
21 Mar
'16
7:22 a.m.
On Mon, Mar 21, 2016 at 12:32 PM, Steven D'Aprano
That's one way of thinking about it. But I don't think it is helpful to think of it as setting an invisible flag "a break was hit inside the loop", and then testing it. I think that a more natural way to think about it is that "break" jumps out of the entire for...else compound statement. This has the big advantage that it actually matches what the byte code does in all the versions I've looked at.
Exactly. I came across this situation in a C++ program, and ended up
writing the 'break' as a 'goto' - something like this, but with better
names:
for (int i=0;i