comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: Trivial Ada question
Date: Fri, 05 Jul 2002 22:25:32 GMT
Date: 2002-07-05T22:25:32+00:00	[thread overview]
Message-ID: <3D261D77.1060707@attbi.com> (raw)
In-Reply-To: mailman.1025773383.11604.comp.lang.ada@ada.eu.org

Grein, Christoph wrote:


> This was a joke, wasn't it? Is this really better than a simle and innocent and 
> nearby goto? A one-time 'loop' enclosing another work loop...
...
> I have to confess that I have not needed a goto in so many years, but the goto 
> solution is one of the simplest solutions of all those presented.


I totally agree.  However, there is a "reasonable" nested loop version...

   INCREMENT:
     loop
       for I in A'Range loop
         exit INCREMENT when condition (A (I));
       end loop;
       N := N + 1;
       exit INCREMENT;
     end loop;

Again the compiler has a chance to generate the correct simple code. 
But we still haven't done anything about the fact that the inner loop 
has two exits that need to be tested.  (The outer loop has a single exit 
and doesn't add any real complexity to the program flow.)

Which is why this discussion sort of bothers me.  The underlying 
complexity of the algorithm can be hidden, but who are you hiding it 
from?  It had better not be the test team.  And that is why I like the 
goto here.  It screams to the testers (and other readers) that the water 
  is deep here.  You have to insert a mental bookmark and read the two 
paths separately.

In fact, the I would probably stick in a comment:
  -- This loop must have two exits.

It is the "must have" that is key, not how it is implemented.




  parent reply	other threads:[~2002-07-05 22:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-04  8:59 Trivial Ada question Grein, Christoph
2002-07-04  9:15 ` Lutz Donnerhacke
2002-07-05 22:25 ` Robert I. Eachus [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-06-28  9:07 Reinert Korsnes
2002-06-28 10:10 ` David C. Hoos, Sr.
2002-06-28 10:54   ` Reinert Korsnes
2002-06-28 10:57     ` Reinert Korsnes
2002-06-28 11:33       ` David C. Hoos, Sr.
2002-06-28 11:44     ` Ted Dennison
2002-06-28 21:38       ` Steven Deller
2002-06-28 12:29     ` Steve Sangwine
2002-07-03 18:59   ` Robert I. Eachus
2002-07-03 19:41     ` Darren New
2002-07-04  8:28       ` Lutz Donnerhacke
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox