Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!mcsun!ukc!tcdcs!swift.cs.tcd.ie!vax1.tcd.ie!cbuckley From: cbuckley@vax1.tcd.ie Newsgroups: comp.lang.c Subject: Re: Errors aren't that simple Summary: Just my two pence worth Message-ID: <5819.25f7a840@vax1.tcd.ie> Date: 9 Mar 90 12:57:35 GMT References: <8192@hubcap.clemson.edu> <17000003@hpcvra.CV.HP.COM> Organization: Computer Laboratory, Trinity College Dublin Lines: 53 In article , emuleomo@paul.rutgers.edu (Emuleomo) writes: > Actually, I think the 'break' as used in the switch stmt was one of the few > mistakes Dennis Ritchie made when designing the C language. By using > 'break' both to end a 'case', and to exit a loop, he overloaded the meaning of > 'break' and thus made it impossible to jump out of a switch that is embedded > within a loop without using a flag or a GOTO! I always thought "break" jumps out of the innermost construct - I presume you mean that it is impossible to jump out of the loop as a result of one of the cases in the switch() (which is imbdedded in the loop). At college, we're taught that this is bad programming practice anyway! (Yes, yes, I *know* that there are times when... etc... etc...) > Was he trying to conserve keywords? In hindsight, I think 'endcase' would have > been a better choice. However, I do kind of agree with this. It would make programs that bit easier to read - especially as a "switch" cannot really be considered a loop, so it is a bit peculiar to use a statement which implies "breaking" out of it. > The other less serious flaw in C is the do...while contruct. > I kind of prefer PASCAL's repeat....until construct myself. How can this be a flaw? The two constructs are identical except for the fact that the condition is reversed in do { } while(); If you *really* want a repeat{}until();, and you're not worried about using #define to redefine language features (and no, I do *not* want to get back into the "re: #define OR ||" argument over this), you can do : #define repeat do #define until(x) while(!(x)) *********NOTE - I would NEVER do this!!!!!!!*************** *********PLEASE do NOT send angry followups!*************** *********I KNOW it is unsound programming practice********* *********I KNOW it defeats the compiler's error-trapping*** but this is really unnecessary, as do...while is just as flexible as repeat...until - after all, every condition has a reverse. exit(0); Colm +-----------------------------------------------------------------+ | Colm Buckley. (Computer Science, Trinity College, Dublin) | | | | EMAIL : cbuckley@vax1.tcd.ie | | Phone : Dublin 770101 | +---+---------------------------------------------------------+---+ | Beware of a programmer with a screwdriver... | +---------------------------------------------------------+