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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,8002154d2966e1a1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-05 09:40:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fr.usenet-edu.net!usenet-edu.net!oleane.net!oleane!nnrp.oleane.net!not-for-mail From: "Jean-Pierre Rosen" Newsgroups: comp.lang.ada Subject: Re: Local vs global variables in ADA Date: Tue, 5 Nov 2002 18:38:08 +0100 Organization: Guest of France Telecom Oleane's newsreading service Message-ID: References: <5Ldx9.3695$151.38236@weber.videotron.net> <3DC5D1B7.1060707@acm.org> <3DC6DD54.10200@acm.org> NNTP-Posting-Host: mailhost.axlog.fr X-Trace: s1.read.news.oleane.net 1036517765 2835 195.25.228.57 (5 Nov 2002 17:36:05 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Tue, 5 Nov 2002 17:36:05 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Xref: archiver1.google.com comp.lang.ada:30390 Date: 2002-11-05T18:38:08+01:00 List-Id: "Stephen Leake" a �crit dans le message news: u3cqg9b8l.fsf@gsfc.nasa.gov... > Fraser Wilson writes: > > > ... Isn't there a preference hierarchy from for loop to while > > loop to loop? I.e. use a for loop whenever possible, failing that a > > while loop, and as a last resort a loop with an exit. OK, and as a > > last last resort use a goto. > > In my style guide, I use a for loop _only_ if the loop will _always_ > be executed exactly as indicated in the "for" part. No other loop > exits allowed. > I beg to differ. A for loop preserves you from a number of problem, especially when dealing with limit cases. Try to write a loop that does *exactly* what for does, and you'll see that there are lots of benefits in using for. For example, I always use a for in a search loop, which exits when the element is found. In Pascal, a for loop was always done entirely; you have to be aware that Ada is different in that respect, but that does not mean that you should not use a more powerful construct when you can. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr