Breaking out of several nested loops
Dick Dunn
rcd at opus.UUCP
Fri Oct 12 05:36:32 AEST 1984
> >> The correct way to break out of multiply nested control constructs (using the
> >> example in the referenced article) without using 3 separate boolean flags is:
>...
> >> while(...){
>...
> >> goto Out;
>
> Very UNstructured!!!!!!!!!!
>
> Try the following:
...and the parent article suggests ripping this nest out into a separate
procedure which has, as parameters, all of the variables needed in the nest
of control constructs--this allows replacing the "goto" with a "return".
I guess the trailing-line-eater bug got the parent article, 'cause there
wasn't a ":-)" at the end.
I'm sure glad to see that someone would violate all concepts of modularity
(yanking part of the innards out of a procedure), clean interface (defining
a new procedure without regard to how many parameters might be needed),
and, dare I say the word, efficiency. No, really, I AM glad about that,
because the more "programmers" there are who bow to the sacred "structured"
idol and who stupidly believe "structured"=="no goto's", the longer I will
be able to be paid an absurdly high salary for being able to produce real
software (though it's sometimes painful to do maintenance on code written
by a "structured code" dogmatist).
--
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