A good use of a bad feature
Barry Margolin
barmar at mit-eddie.MIT.EDU
Sun May 4 16:48:32 AEST 1986
In article <1298 at umcp-cs.UUCP> jim at umcp-cs.UUCP (Jim Williams) writes:
>... the fall through case statement is among the least
>defensible of C's features.
The only defense I can think of it is that it is more easily transformed
into the non-fall-thru version than the other way around. All you have
to do is add lots of "break" statements. If you want the effect of the
fall-thru style in a language that only executes one case, you must
either duplicate code or use lots of gotos in many cases. Note that
this would not be so for your "12 Days of Christmas" program, because it
could easily be implemented as a for loop that invoked each appropriate
case in turn. But in the cases where the alternatives are not indexed
so nicely it would not work.
However, I agree with you that it is not really a necesary feature.
--
Barry Margolin
ARPA: barmar at MIT-Multics
UUCP: ..!genrad!mit-eddie!barmar
More information about the Comp.lang.c
mailing list