[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems/risks due to programming language, stories requested



 From dave@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@hubcap.clemson.edu