The Sins of K&R

Christopher R Volpe volpe at underdog.crd.ge.com
Fri Sep 28 04:53:53 AEST 1990


In article <2487 at lectroid.sw.stratus.com>, jmann at angmar.sw.stratus.com
(Jim Mann) writes:
|>This still doesn't do everything you might want. It doesn't handle
|>the situation in which you do something for one case and then 
|>fall through to the next to do some additional stuff:
|>
|>switch(ch)
|>     {
|>     case 'a':
|>	   do_a();
|>     case 'b':
|>           do_a_or_b();
|>	   break;
|>	.
|>	.
|>	.
|>     }     

Ok, how about requiring the programmer to make it explicit when he/she
wants it to fall through, rather than making that the default? Like so:

switch(ch)
     {
     case 'a':
        do_a();
        continue;
     case 'b':
        do_a_or_b();
     }

or perhaps allow matching more than one case:
switch(ch)
     {
     case 'a':
        do_a();
     case 'a','b':
        do_a_or_b();
     }

This probably belongs in alt.lang.cfutures...
|>
|>Jim Mann
|>Stratus Computer
|>jmann at es.stratus.com
                                                      
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.lang.c mailing list