On Wed, Dec 29, 2010 at 12:09:38PM -0500, M.L. wrote: > On Wed, Dec 29, 2010 at 12:07 PM, Byron Jeff = wrote: > > BTW I would allow for fallthrough, but simply not make it the default. = It > > would have been simple to have fallthrough occur with the use of the > > continue statement. In my view the last snippet should be written as: > > > > > > choice =3D 1; > > switch (choice) { > > =A0 case 1: continue; > > =A0 case 2: continue; > > =A0 case 3: printf("1,2, or 3 was picked\n"); > > =A0 =A0 =A0 =A0 =A0 break; > > =A0 default: printf("other was picked\n"); > > =A0 =A0 =A0 =A0 =A0 break; // Unneccessary but often put in for consist= ency. > > } > > >=20 > I'm not sure if you've thought this through fully. The 'continue' > statement is for going to the next iteration of a loop. Adding it's > use in a case statement would make ambiguous cases (no pun intended) > such as: >=20 > while(inbyte =3D getbyte() ) > { > switch(inbyte) > { > case 1: > .... > continue; // Go to next case or next iteration of loop? > case 2: > ... > }; > } I have thought this through fully. In C break and continue statements affect the closest enclosing control structure that statement is valid for. In you example above, with my modifications, it would go to the next case and is completely unambiguous. Consider the perfectly valid C construct: while(inbyte =3D getbyte() ) { switch(inbyte) { case 1: .... break; // leave switch or leave loop? case 2: ... }; } There's no ambiguity. Since break affects switches, and this break is in a currently open switch, it affects the switch and not the while loop. Of course all of this is a moot design discussion since none of these changes can be made in the existing language precisely because it'll break 10 billion lines of already generated code. I was just complaining that K&R made a poor choice by choosing to make the minority opinion the default. BAJ --=20 Byron A. Jeff Department Chair: IT/CS/CNET College of Information and Mathematical Sciences Clayton State University http://cims.clayton.edu/bjeff --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .