comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: How to implement a continue statement in Ada?
Date: 1998/09/01
Date: 1998-09-01T00:00:00+00:00	[thread overview]
Message-ID: <m3ww7o6wdq.fsf@mheaney.ni.net> (raw)
In-Reply-To: 35EB6C10.D85EBCF2@physics.purdue.edu

"Robert T. Sagris" <robs@physics.purdue.edu> writes:

> What I was asking; how would implement the code given, which really is
> just a general example, in Ada. Specifically so you could use it any
> any loop were you needed to skip an iteration.

As has been pointed out, THE way to implement continue in Ada is to use
a goto:

for I in X .. Y loop
   <do some work>

   if P then
      goto Continue;
   end if;

   <do some more work>

   <<Continue>> null;
end loop;


As Robert pointed out, if you label the loop, then you can include the
loop label in the name of the target of the goto (this is a stylistic
convention):

Paint_House:
for I in X .. Y loop
   <do some work>

   if P then
      goto Continue_Paint_House;
   end if;

   <do some more work>

   <<Continue_Paint_House>> null;
end loop Paint_House;





  reply	other threads:[~1998-09-01  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <35EA8153.7BFC91E3@physics.purdue.edu>
1998-08-31  0:00 ` How to implement a continue statement in Ada? Robert I. Eachus
1998-08-31  0:00   ` Robert T. Sagris
1998-09-01  0:00     ` Matthew Heaney [this message]
1998-08-31  0:00 ` Norman H. Cohen
1998-09-01  0:00 ` alan walkington
1998-09-02  0:00   ` Dr Richard A. O'Keefe
1998-09-02  0:00     ` Matthew Heaney
1998-09-02  0:00     ` alan walkington
1998-09-03  0:00     ` dewarr
2000-02-08  0:00 Oliver Kellogg
2000-02-08  0:00 ` David Starner
2000-02-08  0:00   ` Aidan Skinner
2000-02-09  0:00     ` David Starner
2000-02-10  0:00       ` Aidan Skinner
2000-02-09  0:00     ` Ted Dennison
2000-02-12  0:00       ` Jeff Carter
2000-02-14  0:00       ` Oliver Kellogg
2000-02-08  0:00 ` Ted Dennison
2000-02-09  0:00   ` Roger Barnett
  -- strict thread matches above, loose matches on Subject: below --
1998-08-31  0:00 Robert T. Sagris
1998-09-01  0:00 ` dewarr
1998-09-01  0:00 ` Dr Richard A. O'Keefe
1998-09-01  0:00   ` dewarr
1998-09-03  0:00     ` Dr Richard A. O'Keefe
1998-09-03  0:00       ` dennison
replies disabled

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