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: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public From: "Dan Higdon" Subject: Re: Software landmines (was: Why C++ is successful) Date: 1998/08/19 Message-ID: #1/1 X-Deja-AN: 382768777 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> X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 X-Abuse-Info: Otherwise we will be unable to process your complaint properly X-Complaints-To: abuse@GigaNews.Com X-Trace: FzFaaW9d7+Npqi348AeoooOoo4ksOeO8DToMBR+NsUBceQFPXz1e6TrbbAM0j90/s//XSQmHOsas!/2WX5ujb2UGB NNTP-Posting-Date: Wed, 19 Aug 1998 16:04:17 CDT Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-08-19T00:00:00+00:00 List-Id: adam@irvine.com wrote in message <6rf59b$2ud$1@nnrp1.dejanews.com>... >Now, here are a couple arguments on the other side: >(2) (This one is about "continue", since Charles Hixson later argued that this >was also superior to "goto" for the same reasons.) If you have a loop that >looks like: > > while (blah-blah) { > some-if-statements... > some-more-if-statements... > > xxx; > yyy; > zzz; > } > >someone reading the program might assume that xxx, yyy, and zzz are always >going to happen before the loop repeats. So if there's something new that >needs to be done during every loop iteration, it looks like you can just add >it to the end of the loop, after zzz. If there's a "continue" statement >somewhere above that, this assumption is incorrect and your modification may >well be wrong. If you replace the "continue" with a "goto", at least there >will be a label somewhere toward the bottom of the loop, alerting you to the >fact that you will have to decide whether to put the new code before or after >the label, or look for the place where this label is goto'ed. In fact, this >is exactly why I stopped using "continue" when I was a C programmer. (I >didn't replace them with goto's, I used Boolean flags instead.) So, you've actually changed the algorithm of your code, added an unnecessary data item and added yet another compare/branch to avoid a well understood (IMHO) construct of the C language? Perhaps I'm the only one who thinks writing code that will execute efficiently is equally important as writing readable code. If I didn't care about efficiency, I sure wouldn't be using a 3rd generation procedural language (OO or not) - there are (IMHO) many more succinct and mathematically rigorous languages out there than C or Eiffel (ML and Haskell come to mind, niether of which have gotos, fwiw). I'm not trying to start a language war - I'm pointing out that gotos and the implicit goto forms (break, continue, etc) are a tool of the language. They wouldn't be there if you NEVER needed them. So if you have a case that warrants their use, you should use them, rather than trying to hamstring yourself with hokey constructs. If you *need* that boolean value later, then by all means add it. But I think that using a boolean flag to erase a GOTO is not contributing to the solution, just adding inefficiency into the generated code, and one more symbol for the programmer to have to track. ---------------------------------------- hdan@charybdis.com "Throwing fire at the sun"