This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Statements: break and continue


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]