Re: "continue/next" for "loop"

From: Robert I. Eachus (rieachus_at_comcast.net)
Date: 11/03/03


Date: Mon, 03 Nov 2003 11:49:42 -0500

Peter Hermann wrote:

> assuming the number of keywords 69 constant,
> we could imagine these:

I actually think we are going to get one or two new reserved words in
Ada 200X.

> goto loop [loopid];
>
> or
>
> exit [loopid] not [when ...];

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. ;-)

and

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

For the first case, I think that "exit loop" is probably the preferred
notation. It really is a goto in disguise, but one that need not be
prohibited by those coding standards that prohibit gotos. ;-)

For the second, I am not sure whether "goto loop" or "goto end" is
better. In either case it really is a goto. Other possibilities
include "goto for" and "goto while," but this construct will IMHO often
be used in loops with no for or while clauses.

Back to the earlier discussion about "with and use," I think that "exit
loop" and "goto loop," if added to the language would clearly enhance
readability and maintainability.

-- 
 
Robert I. Eachus
100% Ada, no bugs--the only way to create software.


Relevant Pages

  • Re: how do people feel about exit function from loop
    ... stand out to me far better than a For Next loop for that, ... line, the line that starts the loop, I know ALL the exit conditions for the ... And now we get back to why Goto is "silly" when Exit is not. ... as I have knowledge of only a few languages. ...
    (microsoft.public.vb.general.discussion)
  • Re: Using Wildcards in a Select Case Statement ?
    ... you could, as above, use Exit Do. ... I have never *and I mean NEVER* needed a GoTo ... I have found a fair number of cases where a GoTo simplifies the code ...
    (microsoft.public.vb.general.discussion)
  • Re: Iteration in lisp
    ... state machine is just a tagbody and goto. ... But if you need to change the state-transition-matrix in the middle ... loop and either table-driven or separate-functions for defining the ... (tagbody state1 (trace-state1 aux) ...
    (comp.lang.lisp)
  • Re: COBOL aint quite dead - yet !
    ... of control there is nothing wrong with goto. ... The loop is entirely abstracted away. ... Then we have well-formed loops with a single invariant and a looping ...
    (comp.lang.cobol)
  • Re: I miss loop
    ... I refered to exit sub where I meant exit do. ... I'm not sure but I suspect the functionality of the not in VB.net 2003 loop/continue statement would work more like the nested loops alternative than the goto alternative. ... In a nested loop situation the exit sub would exit the inner loop and therefore you'd re-enter the loop with any variables declared inside the loop being refreshed, for lack of a better word. ...
    (microsoft.public.dotnet.languages.vb)