problems/risks due to programming language, stories requested
William Thomas Wolfe, 2847
billwolf%hazel.cs.clemson.edu at hubcap.clemson.edu
Sat Mar 3 09:15:22 AEST 1990
>From dave at micropen (David F. Carlson):
>> For what it's worth, my personal opinion is that C lends itself to
>> precisely the kinds of errors noted above--when does break work and when
>> doesn't it, and why in God's name do you need it in switch statements in
>> the first place, etc.
>
> A multi-case switch is very handy in many situations to reduce identical
> treatments for similar cases.
So is a multi-alternative case, as provided by Ada:
case Foo is
when 1 | 3 | 5 =>
statement1;
when 2 | 4 | 6 =>
statement2;
when others =>
statement3;
end case;
The difference is that Ada takes care of exiting the case statement
for you, whereas C requires (unsafely) that you use a break to avoid
being sucked into the code associated with subsequent cases.
Bill Wolfe, wtwolfe at hubcap.clemson.edu
More information about the Comp.lang.c
mailing list