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-05 05:56:21 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-05!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!claveman From: claveman@grzorgenplatz.net (Charles H. Sampson) Newsgroups: comp.lang.ada Subject: Re: Local vs global variables in ADA Date: Tue, 5 Nov 2002 05:53:55 -0800 Organization: NetHere Inc. Message-ID: <1fl5uz5.x1tu5v11ap2aeN%claveman@grzorgenplatz.net> References: <5Ldx9.3695$151.38236@weber.videotron.net> <3DC5D1B7.1060707@acm.org> <3DC6DD54.10200@acm.org> User-Agent: MacSOUP/2.4.6 Cache-Post-Path: news-1.nethere.net!unknown@ppp-66-63-134-182.sndg-pm4-2.dialup.nethere.net X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:30381 Date: 2002-11-05T05:53:55-08:00 List-Id: Fraser Wilson wrote: > Jeffrey Carter writes: > > > True. But since at the Ada launch on 1980 Dec 10, some of those people > > said that the language contained "goto" primarily to facilitate > > automated translation from languages such as FORTRAN 66, and "while" > > primarily to facilitate such translation from languages such as Pascal, > > On the "while" comment: are you (or were they) referring to the fact > that a while loop can be expressed as a loop/exit when/end loop > construction, or is there something about while loops that should be > avoided? 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. > > Fraser. I don't know what the "founders" intended but how's this for a rule: Use a for-loop only when it's appropriate, use a while-loop only when it's appropriate, use an "infinite" loop in all other cases. :-) Seriously, here's what I try to do: use the for-loop and while-loop only when they express the loop's termination condition. In other words, do not use exit statements within loops of these forms; if a loop requires an exit statement, then use an "infinite" loop instead. Unfortunately, my will power is often too weak to overcome the convenience of the automatically declared counting variable of a for-loop. I'm much better with while loops. Charlie -- For an email response, my real user name is csampson and my ISP is inetworld.net.