Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: problems/risks due to programming language Message-ID: <12134@goofy.megatest.UUCP> Date: 23 Feb 90 22:15:26 GMT References: <2903@goanna.oz.au> Organization: Megatest Corporation, San Jose, Ca Lines: 35 From article <2903@goanna.oz.au>, by ok@goanna.oz.au (Richard O'keefe): > There's been a lot of discussion about the "switch" statement. > What people seem to have missed is that there are TWO debatable > features about C's "break" statement, one of which was NOT > present in C's grandfather BCPL. I'll add a third one. Or maybe it's just a bug in the compiler I use. I've been programing in C full time for about six years now, so I don't make many mistakes, but I made this one the other day: enum bar { biff, bam, boom }; proc() { enum bar foo; /* ... */ switch(foo) { case biff: do_this(); break; case bad: do_that(); break; boom: do_the_other(); break; } } (The cases were separated by more lines of code.) The compiler loved it. Sun's cc allows this if the enumeration is declared globally, but not if it is declared within a block, if I remember correctly. Of course, testing exposed the mistake, and a fellow whom I asked to "look at this and see what I'm missing," looked at it and saw what I was missing.