From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public X-Google-Thread: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public From: "Gene Gajewski" Subject: Re: Structured programming (Re: Software landmines (was: Why C++ is successful)) Date: 1998/08/21 Message-ID: <6rl0o7$n9$1@birch.prod.itd.earthlink.net>#1/1 X-Deja-AN: 383503971 References: <6qfhri$gs7$1@nnrp1.dejanews.com> <35cb8058.645630787@news.ne.mediaone.net> <902934874.2099.0.nnrp-10.c246a717@news.demon.co.uk> <6r1glm$bvh$1@nnrp1.dejanews.com> <6r9f8h$jtm$1@nnrp1.dejanews.com> <6renh8$ga7$1@nnrp1.dejanews.com> <6rf59b$2ud$1@nnrp1.dejanews.com> <35dc6bf4.5328251@news.erols.com> <6rhpi5$pe7@newshub.atmnet.net> X-Posted-Path-Was: not-for-mail X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 X-ELN-Date: Fri Aug 21 16:44:07 1998 Organization: EarthLink Network, Inc. Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-08-21T00:00:00+00:00 List-Id: Darren New wrote in message <6rhpi5$pe7@newshub.atmnet.net>... >|My point is that 'return' applies a default discipline to 'goto'. In >|fact it's so useful that it now becomes OK to use 'return' quite >|liberally. This affords much flexibility. > > >Actually, having "return" in the middle of a function can be just as bad or >worse than having a goto to the end of a function. > >The advantage of structured programming is that each construct has one entry >and one exit. You can look at >while (foo) > Goto's are always questionable, and really only come into play where C/C++ is being used in an area where assembler traditionally would be used. There are times when you can effectively use C in place of assembler, and if so, should be done sincve C is much more readable than assembler. It's quite common to use goto's in high speed interrupt handlers - where in assembly you would doing just that. A return is not the same thing as a goto - since a goto can 'go' anywhere it wants to, but a return can only exit a function, and directly at that. The advantage of using returns within a function is minimization of decision points or conditions at any particular line within the code. A strict interpretation of 'one exit point only' usually winds up genrating multiple nested if-elses, only serving to confuse. If a particular condition invalidates an entire group of further decision points, there's no sense in evaluating them. If the condition does not invalidate, then we can safe proceed without having nested logic.