Sometimes when I am programming, I find that some particular control structure would be very useful to me, but is not directly available in my programming language. I think my
Labeled loops are something I find myself missing sometimes from mainstream languages. e.g.,
int i, j;
for outer ( i = 0; i < M; ++i )
for ( j = 0; j < N; ++j )
if ( l1[ i ] == l2[ j ] )
break outer;
Yes, I can usually simulate this with a goto
, but an equivalent for continue
would require you to move the increment to the end of loop body after the label, hurting the readability. You can also do this by setting a flag in the inner loop and checking it at each iteration of the outer loop, but it always looks clumsy.
(Bonus: I'd sometimes like to have a redo
to go along with continue
and break
. It would return to the start of the loop without evaluating the increment.)