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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cf677878aa77e0d8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-13 11:11:33 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3B4F2962.25BB60FF@boeing.com> Subject: Re: an infinate loop Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Fri, 13 Jul 2001 14:11:27 EDT Organization: http://www.newsranger.com Date: Fri, 13 Jul 2001 18:11:27 GMT Xref: archiver1.google.com comp.lang.ada:9919 Date: 2001-07-13T18:11:27+00:00 List-Id: In article <3B4F2962.25BB60FF@boeing.com>, Jeffrey Carter says... > >Ted Dennison wrote: .. >This is bad advice. The form that uses positive logic is best. > loop >exit when End_Of_File; > >uses positive logic, and is better than > >while not End_Of_File loop > >which uses negative logic. All of the exits in this program use positive >logic. In general, exit tends to use positive logic and while tends to >use negative logic. True. As a seperate issue, I'd say it is better when you can rearrange the condition so it uses positive logic. Unfortunately, you can't always do that, and this is one of those cases. So you have to look at the overall effect one way vs. the other and ask yourself which is clearer. >At the "Ada Launch" (1980 Dec 10), Ichbiah, Barnes, and Firth introduced >the recently renamed Ada language (MIL-STD 1815, formerly Green, now >known as Ada 80) to the world. They said "while" was in the language >primarily to support translation from languages such as Pascal, and >advised using the "loop ... exit when" format in new code. Interesting. Do you have a reference for this (or perhaps you were there)? It seems like rather bad logic, as you can clearly construct any of the other kinds of loops with "loop" and "exit". I do remember hearing (second hand. I'm not trying to claim I was there either) a quote similar to this about "goto". There are those here who would dispute its validity in that context too though. The issue with "for" and "while" is that they are more controlled, constrained variants of "loop". As such, they are useful for designating that this is a loop that behaves in one of those controlled, constrained type of ways. If it is just "loop", then the reader has to assume its control structure could be pretty much *anything*, and go reading through all the code inside to see what it actually is. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com