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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8002154d2966e1a1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-06 09:49:42 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Local vs global variables in ADA Date: 06 Nov 2002 12:34:27 -0500 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <5Ldx9.3695$151.38236@weber.videotron.net> <3DC5D1B7.1060707@acm.org> <3DC6DD54.10200@acm.org> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1036604727 17257 128.183.235.92 (6 Nov 2002 17:45:27 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 6 Nov 2002 17:45:27 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:30476 Date: 2002-11-06T17:45:27+00:00 List-Id: Robert A Duff writes: > Stephen Leake writes: > > > Never use a "while" loop. Mostly because "exit when" is much clearer, > > partly because I've used other languages that had slightly different > > definitions of "while", and I can't keep them straight. > > Like what? I mean, which languages have different definitions of > "while" loops, and what are the differences. I thought "while" loops > were one of the few cases where there is pretty much agreement on the > semantics across languages. I had hoped someone else would actually answer your question, but they didn't. At the moment, I only use Ada and C, so I don't really remember what the issues are precisely. What I do remember is being confused about whether the loop body executes once for a "false" while condition. Especially when the "while" is at the end. I believe different languages (I've used Pascal, C, COBOL, Fortran, lisp, Ada) do this differently. But I could be wrong; it could be that I could just never remember the (common) rule. Hmm. Checking my ANSI C manual, I see that if "while" is at the top, the loop body is not executed if the condition is false. If "while" is at the bottom, the loop body is executed once if the condition is false. Ada only allows "while" at the top, and it has the same rule as C. Anyway, I see no reason to strain my limited supply of brain cells trying to remember this, when loop/exit/end loop covers all the cases, and is perfectly clear. -- -- Stephe