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
- Subject: Re: Statements: break and continue
- From: Branko Čibej <brane at xbc dot nu>
- Date: Sat, 28 Jul 2001 11:37:39 +0200
- References: <000701c1173a$65237890$0200a8c0@lockdown>
LocKDowN wrote:
>Can't there be a break(depth) and continue(depth) to specify the deepness to
>act on?
>example:
>
>[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
> }
> }
>}
>[some code]
>
>This would be highly convenient as the workaround is unattractive.
>PHP has this great feature, surprisingly.
>Perhaps you have not added this for standards compliance?
>I'm mailing about this because this issue has always disturbed me.
>I'd like to have some insight on this matter...
>
I think this is a miserable feature, and fervently hope it never becomes
part of C/C++. Using it makes code less maintainable, because adding a
level of nesting to the loop means you have to carefully examine and
change all the numbers on the break and continue statements. Judicions
use of goto is safer, IMHO. Besides, it smells a bit like fortran's
arithmetic if.
A somewhat better design would be based Perl's labelled loops.
And anyway, this is off topic for this list. You should take it to
comp.std.c.
Brane