Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!bloom-beacon!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: <4462@buengc.BU.EDU> Date: 6 Oct 89 18:08:41 GMT References: <6396@ficc.uu.net> <725@thor.wright.EDU> <6430@ficc.uu.net> <4447@buengc.BU.EDU> <867@crdos1.crd.ge.COM> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Distribution: na Organization: Boston Univ. Col. of Eng. Lines: 50 In article <867@crdos1.crd.ge.COM> davidsen@crdos1.UUCP (bill davidsen) writes: >In article <4447@buengc.BU.EDU>, bph@buengc.BU.EDU (Blair P. Houghton) writes: > >| 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; > > This doesn't do the same thing at all. In the original the "donum:" >code was only executed if a case was matched in the switch. Your example Quite so. >executes it everytime. As you mentioned but didn't show you would have >to define a bunch of flags and stuff to make this work. Not really: switch(ch = format_char) { /* Switch body exactly as above */ } switch(ch) { case 'd': case 'o': case 'x': case 'u': the stuff I put under donum; break; default: break; } I only did the extra assignment to give the switch body full use of the variable format_char. It may well be unnecessary in our hypothetical example. --Blair "One variable of indeterminate necessity and an improvement in the maintainability of the do-for-all-flags code. How many marks out of ten, Dr. Structmember-Offset?"