Good code for sometimes shared case

Gregory Smith greg at utcsri.UUCP
Mon Apr 21 14:14:21 AEST 1986


In article <2600045 at ccvaxa> aglew at ccvaxa.UUCP writes:

>Structured programming != Gotoless programming

Right on.
What was really ironic about the original posting ( using if(0){...} )
was that it was obviously an attempt to avoid those satanic g*t*'s, and
therefore wind up with structured code. However, the structure of the
if's was twisted around the structure of the switch statement, so the
result was worse (less structured) than being honest and using goto's.
That was made possible by the lax rules applied to 'case' labels in C
(as opposed to, say, Pascal).
It was, in a way, analogous to
	while con1 ... if con2 ... end_while .. end_if
Which could be made to work as a 'while' with a 'break' if compilers
would allow it. I am not, of course, saying that they should. How about
producing a warning if a case label is not *directly* inside the {}'s
of the switch?
-- 
"If you aren't making any mistakes, you aren't doing anything".
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg



More information about the Comp.lang.c mailing list