From: "Jean-Pierre Rosen" <rosen@adalog.fr>
Subject: Re: Local vs global variables in ADA
Date: Tue, 5 Nov 2002 18:38:08 +0100
Date: 2002-11-05T18:38:08+01:00 [thread overview]
Message-ID: <aq8vi4$2oj$1@s1.read.news.oleane.net> (raw)
In-Reply-To: u3cqg9b8l.fsf@gsfc.nasa.gov
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]
"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> a �crit dans le message
news: u3cqg9b8l.fsf@gsfc.nasa.gov...
> Fraser Wilson <newsfraser@blancolioni.org> 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
next prev parent reply other threads:[~2002-11-05 17:38 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-03 18:17 Local vs global variables in ADA Roger
2002-11-03 19:03 ` Per Sandbergs
2002-11-03 19:31 ` Eric Jacoboni
2002-11-04 1:47 ` Jeffrey Carter
2002-11-04 13:27 ` Wes Groleau
2002-11-04 20:48 ` Jeffrey Carter
2002-11-05 8:43 ` Fraser Wilson
2002-11-05 13:53 ` Charles H. Sampson
2002-11-06 4:59 ` R. Tim Coslet
2002-11-05 17:28 ` Stephen Leake
2002-11-05 17:38 ` Jean-Pierre Rosen [this message]
2002-11-05 19:57 ` Jeffrey Carter
2002-11-06 9:11 ` Jean-Pierre Rosen
2002-11-05 20:26 ` Vinzent Hoefler
2002-11-05 23:14 ` Wes Groleau
2002-11-06 9:16 ` Jean-Pierre Rosen
2002-11-06 13:49 ` Wes Groleau
2002-11-05 22:37 ` Robert A Duff
2002-11-05 23:46 ` Larry Hazel
2002-11-06 2:19 ` Dennis Lee Bieber
2002-11-06 13:45 ` Dan Nagle
2002-11-07 0:30 ` Dennis Lee Bieber
2002-11-06 2:15 ` Dennis Lee Bieber
2002-11-06 7:04 ` Martin Dowie
2002-11-06 14:40 ` john mann
2002-11-07 0:25 ` Dennis Lee Bieber
2002-11-07 14:58 ` Robert A Duff
2002-11-07 15:38 ` Jean-Pierre Rosen
2002-11-08 1:43 ` Jeffrey Carter
2002-11-06 7:18 ` Dale Stanbrough
2002-11-06 15:40 ` Rod Chapman
2002-11-06 17:34 ` Stephen Leake
2002-11-10 1:36 ` loop statements, was " David Thompson
2002-11-05 19:54 ` Jeffrey Carter
2002-11-04 13:47 ` Martin Dowie
-- strict thread matches above, loose matches on Subject: below --
2002-11-05 6:42 Grein, Christoph
2002-11-05 15:59 ` Martin Dowie
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox