Article View: comp.lang.misc
Article #4383Re: GOTO controversy
From: Szu-Wen Huang
Date: Thu, 07 Mar 1996 02:01
Date: Thu, 07 Mar 1996 02:01
30 lines
1702 bytes
1702 bytes
John Noland (sinan@cyberramp.net) wrote: [snip] : DON'T use a goto unless it's the only solution to the problem. : You have many alternatives to a goto in your above code. Wrong. 'goto' will never be the only solution. When the 'goto' solution is more elegant than the other choices (which is entirely possible), use 'goto'. : A subroutine should have at most one label. Arbitrary number. Does a subroutine with exactly *two* labels automatically and magically become unreadable? : All goto's should be above that label in the code. Above? You mean all 'goto's should be forward jumps? Why? : The label should be in the same code block or at a more outer : nesting level than the goto itself. : Your code could be easily reorganized to not use a goto. That's the point against using 'goto's. Realize however that a good engineer is usually smarter than blind guidelines. The rules you raised have obvious drawbacks. Personally, the rule I impose upon myself is: "If you use a 'goto', you better have a damn good reason for it and be prepared to explain why all other constructs make the program uglier."
Technical Details
Message-ID:
<4hlg11$dd7@news1.mnsinc.com>Path:
arc1-ca.pugleaf.net!user1.mnsinc.com!huangReferences:
<rcshlds.1.000A6705@mailserv.mta.ca> <Dn8pJ8.nqs@emi.net> <4grt4e$8fg@goanna.cs.rmit.EDU.AU> <4hl8mt$4po@newshost.cyberramp.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!user1.mnsinc.com!huang From: huang@mnsinc.com (Szu-Wen Huang) Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.pl1 Subject: Re: GOTO controversy Followup-To: comp.lang.misc,comp.lang.c,comp.lang.pl1 Date: 7 Mar 1996 02:01:05 GMT Organization: Monumental Network Systems Message-ID: <4hlg11$dd7@news1.mnsinc.com> References: <rcshlds.1.000A6705@mailserv.mta.ca> <Dn8pJ8.nqs@emi.net> <4grt4e$8fg@goanna.cs.rmit.EDU.AU> <4hl8mt$4po@newshost.cyberramp.net> NNTP-Posting-Host: user1.mnsinc.com X-Newsreader: TIN [version 1.2 PL2]