Intelligibility of multibreak loops

mark at cbosgd.UUCP mark at cbosgd.UUCP
Fri Aug 26 11:09:32 AEST 1983


Among programming languages people, multi level breaks and continues
are generally considered a "good thing".  When coupled with a decent
for loop (such as the one in C) and a return statement, the almost
make goto's completely obsolete.  There are two remaining situations
I run across every blue moon that are left:

(1) Error handling.  There are lots of hairy and ugly schemes to deal
with sudden errors.  Software events, such as PL/1 on-units and Ada
exceptions, are one very complex approach.  Non local goto's ala Pascal
are another.  For my money, the setjmp/longjmp mechanism provided by
the C library (not the language!) is prefectly adequate for this one,
although one would like better diagnostics when you mess up.

(2) Reduction to another case.  This is a familiar concept in Mathematics,
where you handle one case by doing some simplification and then saying
"it reduces to this other case".  The same thing is useful in programming.
Within a switch, you want to say, in effect, "go to the label marking the
code to handle the following switch value".  (Note this is a generalization
of the "goto default" situation mentioned earlier.)



More information about the Comp.lang.c mailing list