comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Local vs global variables in ADA
Date: Tue, 05 Nov 2002 19:54:44 GMT
Date: 2002-11-05T19:54:44+00:00	[thread overview]
Message-ID: <3DC8222D.3080601@acm.org> (raw)
In-Reply-To: uadkov23t.fsf@FWILSON.i-did-not-set--mail-host-address--so-shoot-me

Fraser Wilson wrote:
> 
> 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.

The point made by Ichbiah, Barnes, and Firth at the Ada Launch was that 
while loops express the condition for continuation, not exit, and this 
is difficult for beginners to understand, and they usually require the 
use of negative logic (while not End_Of_File), which is often more 
difficult to understand than positive logic; that a loop with an exit as 
its first statement expresses the condition for exit, and this is easy 
for everyone to understand, and it usually uses positive logic (exit 
when End_Of_File). For these reasons they thought the latter form should 
be prefered.

There are as many preference hierarchies as there are people creating 
preference hierarchies. Here's one: use assembler whenever possible, 
failing that use C, failing that use a C derivative, failing that use 
another language other than Ada, and use Ada when forced to at gunpoint. 
I don't happen to agree with it, but I suspect that there are those who 
do. Just because you've seen someone's preference hierarchy doesn't mean 
you should follow it.

I use the rule that you should use the appropriate form of a loop for 
the iteration that's required. If you accept the arguments of "the 
founders", while is never the appropriate form.

-- 
Jeff Carter
"We burst our pimples at you."
Monty Python & the Holy Grail




  parent reply	other threads:[~2002-11-05 19:54 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
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 [this message]
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