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: 103376,f6a85e71d2c330ab X-Google-Attributes: gid103376,public From: Geoff Bull Subject: Re: checking a loop execution Date: 2000/04/20 Message-ID: <38FEFC81.23F3729@acenet.com.au>#1/1 X-Deja-AN: 613563992 Content-Transfer-Encoding: 7bit References: <8dl76u$etf$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@telstra.net X-Trace: nsw.nnrp.telstra.net 956235048 203.35.118.1 (Thu, 20 Apr 2000 22:50:48 EST) Organization: Customer of Telstra Big Pond Direct MIME-Version: 1.0 NNTP-Posting-Date: Thu, 20 Apr 2000 22:50:48 EST Newsgroups: comp.lang.ada Date: 2000-04-20T00:00:00+00:00 List-Id: pumilia@my-deja.com wrote: > > Is there a way to check if a loop has been exited before completion or > if all iterations have been performed? > In fortran the loop index is increased one last time, at the end of > the loop, but in Ada that trick cannot be exploited; the index is not > even defined outside the loop. > I could add a control variable (ivar, in my example) to take care of the > iteration number when exiting, but that would decrease the peformance > of my algorithm > > Example > > procedure loop_test is > > ivar : integer; > > begin > for i in 1 .. 10 loop > if then > ivar := i; > exit ; > end if ; > end loop; > put(ivar,2); > end loop_test; > > thank you for your suggestions I can't see why th solution you have proposed would cause a performance problem, but another solution would be to use a while loop.