This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Statements: break and continue
- To: gcc at gcc dot gnu dot org, lockdown at usm dot dhs dot org
- Subject: Re: Statements: break and continue
- From: dewar at gnat dot com
- Date: Sat, 28 Jul 2001 07:03:32 -0400 (EDT)
<<[some code]
for (int x = 0; x < 10; x++) {
for (int y = 0; y < 10; y++) {
if (x == 5 && y == 8) {
break(2); // get out of BOTH for loops
}
}
}
>>
What a perfectly horrible suggestion IMO. Counting like this is an inherently
unreliable syntactic device, and one that is obviously very susceptible to
maintenance problems.
Labeled loops and exits, as in Ada, make sense, but this counting notation
seems a step backwards. You can always use a goto to achieve this, and I
think in this particular case a goto would be far preferable than the count.
Yes, I know that some programmers these days have been brought up to be
allergic to gotos, so allergic that they will do anything or propose
anything to avoid them, but the fact of the matter is that there are
constructs that are far worse than gotos, and this is one of them!
>>Perhaps you have not added this for standards compliance?
perhaps :-)