Breaking out of several nested loops (& ANSI C)
Dick Dunn
rcd at opus.UUCP
Fri Oct 12 06:10:04 AEST 1984
Bad confusion on the multi-level break issue:
> One of the proposals that was supposed to be brought up before the last
> committee meeting was a way to make breaking out of deeply nested loops
> structured such that the following:
> [illustration of multi-level-break problem]
> would become:
> -- whileloop:
>...
> -- break whileloop;
>...
> The idea is to be able to label while, for and do-while loops and be able to
> use those labels on break and continue statements. This provides for a very
> structured and much more readable and maintainable coding style, in my
> opinion, than the equivalent code using goto's or separate procedures...
>...
> What does everyone think? Is this a worthy attempt at making the language
> more structured and orthogonal? Send in your votes!
The idea for such a language construct is reasonable, but it should not be
muddled into the standardization process. Standards committees working on
existing languages are NOT in the role of designing, or even revamping, a
language. Naturally, they will have to make some changes--but only for
those situations where there is a very real problem in the existing form(s)
of the language.
In fact, the proposed construct does not answer any particular crying need.
Multi-level breaks are comparatively uncommon. They certainly aren't so
common and so much of a problem as to justify a CHANGE to the language.
Finally, the proposed solution has a very interesting characteristic:
Without the extension, the multi-level break has two parts--a
transfer and a label.
With the extension, the multi-level break has two parts--a transfer
and a label.
The notable difference is that with the extension, the label is at a
different point (possibly by quite a distance) than the point to which
control is actually transferred. I'm hard-pressed to see that as an
advantage.
--
Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086
...Relax...don't worry...have a homebrew.
More information about the Comp.lang.c
mailing list