Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!texbell!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: The final word on GOTO (Don't I wis Message-ID: <6430@ficc.uu.net> Date: 5 Oct 89 16:58:02 GMT References: <6396@ficc.uu.net> <725@thor.wright.EDU> Distribution: na Organization: Xenix Support, FICC Lines: 33 Code deleted, see parent article. In article <725@thor.wright.EDU>, bkottman@thor.wright.edu (Brett Kottmann) writes: > This must be really old code since in C, execution falls through > to the next case anywasy; in every case without the goto, it would hit > donum: anyways...(albiet after trying the rest of the case statements) Yes, but if you looked at what the code *does*, you would see that you don't want to execute those statements. > A break usually replaces the goto in that type of code. In this case it wouldn't. Here's a goto-less version of the multiple lead-in case that should have you all puking: switch(format_char) { case 'd': the stuff I put under d; if(0) { case 'o': the stuff I put under o; if(0) { case 'x': the stuff I put under x; if(0) { case 'u': the stuff I put under u; }}} the stuff I put under donum; } I know it's not the best way to remove the gotos, but it's legal C without a single "unstructured" element. It's always possible to "remove" the gotos. It's not always worth it. Structured programming is a discipline, not a game. -- Peter da Silva, *NIX support guy @ Ferranti International Controls Corporation. Biz: peter@ficc.uu.net, +1 713 274 5180. Fun: peter@sugar.hackercorp.com. `-_-' ``I feel that any [environment] with users in it is "adverse".'' 'U` -- Eric Peterson