Path: utzoo!attcan!uunet!van-bc!rsoft!mindlink!a563 From: a563@mindlink.UUCP (Dave Kirsch) Newsgroups: comp.lang.c Subject: Re: problems/risks due to programming language, stories requ Message-ID: <1306@mindlink.UUCP> Date: 14 Mar 90 14:57:14 GMT Organization: MIND LINK! - British Columbia, Canada Lines: 62 > amull writes: > > Msg-ID: <775@s5.Morgan.COM> > Posted: 10 Mar 90 17:50:32 GMT > > Org. : Morgan Stanley & Co. NY, NY > Person: Andrew P. Mullhaupt > BTW - fall through and the 'double duty' break keyword are > definitely examples of C flaws. If you must, flame me, but in > comp.lang.c, (OK?) > > Later, > Andrew Mullhaupt C flaws? Do this in Pascal: switch (i) { case 2 : /* Add 2 to j */ j++; case 1 : /* Add 1 to j */ j++; case 0 : /* Print j out */ printf("%d\n", j); break; default : printf("Illegal value in switch.\n"); abort(); } In pascal you have to: case i of 2 : begin /* Add 2 to j */ j := j + 2; writeln(j); end; 1 : begin /* Add 1 to j */ j := j + 1; writeln(j); end; 0 : begin /* Print j out */ writeln(j); end; else begin writeln('Illegal value in case.'); Halt; end; end; If you take a look at this, you can see how C's break inside a switch is very conveinent. I admit, when I started learning C from when I was a Pascal programmer I thought it was strange, too. But I never saw it as a 'flaw'. I reliezed there must be a reason for it being like that, now that I'm using C, I want it like that. For large switch statements, you can do some really good code reduction using that technique. If you comment it well, it looks fine and runs fine. -- _____________________________________________________________________ Dave Kirsch UUCP: {uunet,ubc-cs}!van-bc!rsoft!mindlink!a563 Voice: (604) 327-4404 a563@mindlink.UUCP Vancouver, British Columbia