problems/risks due to programming language
James Buster
bitbug at lonewolf.sun.com
Fri Feb 23 17:16:58 AEST 1990
In article <8133 at hubcap.clemson.edu> billwolf%hazel.cs.clemson.edu at hubcap.clemson.edu (William Thomas Wolfe, 2847 ) writes:
> 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
I claim that the possibly erroneous replication of code required by the Ada
case statement, e.g.
-- in approximate Ada style
switch foo is
case 5 =>
statement1;
statement2;
statement3;
case 7 =>
statement1;
statement2;
statement3;
end
as compared too C's
switch (foo)
{
case 5:
case 7:
statement1;
statement2;
statement3;
}
is well worth remembering to put in break statements.
--
---------------------------------------------------------------------
James Buster (Domain) bitbug at lonewolf.ebay.sun.com
Mad Hacker Extraordinaire (UUCP) ...!sun.com!lonewolf!bitbug
---------------------------------------------------------------------
More information about the Comp.lang.c
mailing list