Path: utzoo!utgpu!watmath!iuvax!purdue!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: The final word on GOTO (Don't I wis Message-ID: <4447@buengc.BU.EDU> Date: 6 Oct 89 05:17:38 GMT References: <6396@ficc.uu.net> <725@thor.wright.EDU> <6430@ficc.uu.net> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Distribution: na Organization: Boston Univ. Col. of Eng. Lines: 36 In article <6430@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >Code deleted, see parent article. >Here's a goto-less version of the multiple >lead-in case that should have you all puking: Hwuawp! Thanks, Pete. Had the wrong thing for lunch, anyway... :-) > 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. I'd go out of my way to fix it so that I could just do switch(format_char) { case 'd': the stuff I put under d; break; case 'o': the stuff I put under o; break; case 'x': the stuff I put under x; break; case 'u': the stuff I put under u; break; } the stuff I put under donum; Even if it meant (Gasp!) declaring a few variables outside the switch and structuring the rest of my program in such a way as to prevent needing such kludgery... --Blair "At least they'd get initialized properly..."