problems/risks due to programming language
William Thomas Wolfe, 2847
billwolf%hazel.cs.clemson.edu at hubcap.clemson.edu
Fri Feb 23 13:24:08 AEST 1990
>From mjones at fenway.uucp (Mike Jones):
>> By requiring the use of a GOTO during normal processing (as C does
>> with its switch..break system), C encourages its programmers to get
>> into the habit of using its restricted GOTO routinely. As AT&T has
>> recently discovered, that can easily prove to be an expensive habit.
>
% Ah, I see it now. The problem here is that you keep insisting that the
% use of break in switch statements is "normal processing". "Common" it
% certainly is, but the very purpose of break is to *change* "normal"
% processing. The switch statement in C is NOT equivalent to an
% if...else if...else statement group. It is common practice to use the
% break statement to make it behave that way. Is this a design flaw? Quite
% possibly, but it's not the same flaw you're claiming.
On the contrary, this is precisely the flaw I'm pointing out!!!
C's switch statement is badly designed, so badly designed that it is
common practice to use break statements by the dozen in order to get
it to behave reasonably. A more sensible design would give the switch
the semantics of the Ada case statement, thereby saving countless lines
of code through the elimination of all those "break" statements.
Bill Wolfe, wtwolfe at hubcap.clemson.edu
More information about the Comp.lang.c
mailing list