🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3399

Re: GOTO single exit point (was: Re: How to eliminate GOTO?)

#3399
From: Christopher R. Volpe
Date: Tue, 05 Sep 1995 14:24
46 lines
2792 bytes
In article <4258ak$cj7@news0.rain.rg.net>, Paul Long <plong@perf.com> writes:
>volpe@bart.crd.ge.com (Christopher R. Volpe) wrote:
>>In article <41t0sb$15e@news0.rain.rg.net>, Paul Long <plong@perf.com> writes:
>[snip]
>
>I mean the readability problem that Steve McConnell describes in _Code
>Complete_: "It's harder to understand a routine if, reading it at the bottom,
>you're unaware of the possibility that it returned somewhere above."

With all due respect to Mr. McConnell, I don't read code from the bottom up.

>Maybe you misunderstood me. I am _not_ proposing that gotos are a reasonable
>alternative to multiple return statements. Both are bad and avoidable.

Ah... Ok. So you prefer the umpteen-levels-of-if-statement-nesting method?

>
>>I'm not saying there aren't good uses of a goto. There are. But when you see a
>>goto statment, bells and whistles should go off in your head, because it's a
>>source of potential trouble. The more one becomes desensitized to goto
>>statements by frequent use, the less likely one is to notice bad uses, IMO.
>
>I agree. Since I still have the book open, here's another quote from _Code
>Complete_: "Even if gotos aren't confusing when used carefully, once gotos are
>introduced, they spread through the code like termites through a rotting house.
>If any gotos are allowed, the bad creep in with the good, so it's better not to
>allow any of them."

I agree somewhat with the spirit of that, but the conclusion is too absolute.
There are exceptions. 

>
>>Therefore, I use gotos only when the alternative is less readable. This is not
>>true for the general case of multiple return points.
>
>We disagree.

On what? On the use of gotos only when the alternative is less readable? Or my
claim that multiple return statements are more readable than a bunch of 
"goto exit_point;" statements?

--

Chris Volpe				Phone: (518) 387-7766 (Dial Comm 8*833
GE Corporate R&D			Fax:   (518) 387-6560
PO Box 8, Schenectady, NY 12301		Email: volpecr@crd.ge.com
Technical Details
Message-ID: <42hmj1$96o@rdsunx.crd.ge.com>
Path: arc1-ca.pugleaf.net!bart.crd.ge.com!volpe
References: <3vn1ht$kj8@martha.utk.edu> <41cke4$gtd@sparcserver.lrz-muenchen.de> <41glno$3a0@caip.rutgers.edu> <41iebe$kec@news0.rain.rg.net> <41pm80$skp@inferno.mpx.com.au> <DE02nC.B58@eskimo.com> <41t0sb$15e@news0.rain.rg.net> <DE6G2z.JJD@crdnns.crd.ge.com> <4258ak$cj7@news0.rain.rg.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!bart.crd.ge.com!volpe
From: volpe@bart.crd.ge.com (Christopher R. Volpe)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: GOTO single exit point (was: Re: How to eliminate GOTO?)
Date: 5 Sep 1995 14:24:33 GMT
Organization: GE Corporate Research & Development
Sender: volpe@bart (Christopher R. Volpe)
Distribution: world
Message-ID: <42hmj1$96o@rdsunx.crd.ge.com>
References: <3vn1ht$kj8@martha.utk.edu> <41cke4$gtd@sparcserver.lrz-muenchen.de> <41glno$3a0@caip.rutgers.edu> <41iebe$kec@news0.rain.rg.net> <41pm80$skp@inferno.mpx.com.au> <DE02nC.B58@eskimo.com> <41t0sb$15e@news0.rain.rg.net> <DE6G2z.JJD@crdnns.crd.ge.com> <4258ak$cj7@news0.rain.rg.net>
Reply-To: volpe@ausable.crd.ge.com
NNTP-Posting-Host: bart.crd.ge.com