comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: "continue/next" for "loop"
Date: Mon, 03 Nov 2003 18:52:43 GMT
Date: 2003-11-03T18:52:43+00:00	[thread overview]
Message-ID: <%txpb.5381$qh2.2068@newsread4.news.pas.earthlink.net> (raw)
In-Reply-To: <GaOdnQutOP61GjuiRVn-hQ@comcast.com>

Robert I. Eachus wrote:
> But I think in the case of loops, there are clearly two specialized 
> forms of goto that should be considered:
> 
> goto exit; -- exit innermost enclosing loop.
> exit loop; -- alternative syntax. ;-)

This already exists in Ada; it's syntax is

exit;

Without a loop name or when part, exit exits the innermost enclosing loop.

> and
> 
> goto end; -- skip to start of next loop iteration.
> goto loop;
> goto begin;

This doesn't exist. Ichbiah and others were aware of "continue" in C but 
chose not to include it in Ada 83. Did they have a good reason? Is the 
Ada-83 Rationale available on line anywhere?

The problem with this discussion is that we don't know what the OP is 
trying to do; we only know how he is trying to do it, sort of. As 
pointed out elsewhere, the goto's could be converted to "exit Inner;" 
and the statements between "end Inner;" and "end Outer;" removed, with 
no change in behavior, so we don't really even know how the OP is trying 
to do whatever he is trying to do. If we knew what he was trying to 
achieve, rather than how he was trying to do it, we might be able to 
propose an alternative approach that would avoid his problem.

Assuming some way to exit Inner and execute the statements between the 
end of Inner and the end of Outer, we have seen a number of ways to 
achieve this: goto statements, a Boolean flag, and exceptions. Another 
way is to use a dummy loop and exit it:

Outer : loop
    Dummy : loop
       Inner : loop
          ...
          if First then
             ...
             exit Dummy;
          end if;
          ...
          if Second then
             ...
             exit Dummy;
          end if;
          ...
          exit Inner when Third;
       end Inner;
       ...
       exit Dummy;
    end Dummy;
end Outer;

-- 
Jeff Carter
"I blow my nose on you."
Monty Python & the Holy Grail
03




  parent reply	other threads:[~2003-11-03 18:52 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-03 12:55 "continue/next" for "loop" amado.alves
2003-11-03 13:06 ` Lutz Donnerhacke
2003-11-03 13:07 ` Lutz Donnerhacke
2003-11-03 13:25   ` Peter Hermann
2003-11-03 16:49     ` Robert I. Eachus
2003-11-03 18:21       ` (see below)
2003-11-03 18:52       ` Jeffrey Carter [this message]
2003-11-03 20:11         ` Lutz Donnerhacke
2003-11-04  1:23         ` Robert I. Eachus
2003-11-03 13:33   ` James Rogers
2003-11-03 13:46     ` Lutz Donnerhacke
2003-11-03 13:39   ` Dmitry A. Kazakov
2003-11-03 13:54   ` Ole-Hjalmar Kristensen
2003-11-03 14:56     ` Lutz Donnerhacke
2003-11-03 15:08   ` Stefan Lucks
2003-11-03 15:40     ` Lutz Donnerhacke
2003-11-05 10:36   ` Charles Lindsey
2003-11-05 18:05     ` Lutz Donnerhacke
2003-11-06  9:48     ` Martin Dowie
2003-11-07 14:54       ` Charles Lindsey
2003-11-07 16:24         ` Martin Dowie
2003-11-07 17:34         ` Jeffrey Carter
2003-11-05 14:45   ` Jim Rogers
  -- strict thread matches above, loose matches on Subject: below --
2003-11-03 15:44 amado.alves
2003-11-03 22:12 ` Dmytry Lavrov
2003-11-03 22:27 ` Gautier Write-only
2003-11-03 13:54 amado.alves
2003-11-03 13:45 christoph.grein
2003-11-03 14:23 ` Preben Randhol
2003-11-03 15:01   ` Lutz Donnerhacke
2003-11-03 15:19     ` Dmitry A. Kazakov
2003-11-03 18:33       ` Chad R. Meiners
2003-11-03 15:48     ` Preben Randhol
2003-11-03 18:50     ` Georg Bauhaus
2003-11-03 15:00 ` Lutz Donnerhacke
2003-11-03 10:48 Lutz Donnerhacke
2003-11-03 10:51 ` Preben Randhol
2003-11-03 10:55   ` Preben Randhol
2003-11-03 11:01   ` Lutz Donnerhacke
2003-11-04  3:11 ` Steve
2003-11-05 15:54 ` sk
2003-11-06 15:40   ` Stephen Leake
2003-11-06 18:27     ` sk
2003-11-06 15:39 ` Stephen Leake
replies disabled

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