Re: "continue/next" for "loop"

From: see below (yaldnifb_at_blueyonder.co.uk)
Date: 11/03/03


Date: Mon, 03 Nov 2003 18:21:29 GMT

On 3/11/03 16:49, in article GaOdnQutOP61GjuiRVn-hQ@comcast.com, "Robert I.
Eachus" <rieachus@comcast.net> 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. ;-)
>
> and
>
> goto end; -- skip to start of next loop iteration.
> goto loop;
> goto begin;
...
> 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.

Does "goto loop" not imply jumping to a point *after* the for/while test, if
used in for/while loops? "goto end" clearly implies that the for/while test
is to be repeated.

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

Agreed, subject to the above.

-- 
Bill:Findlay chez Blue:Yonder dot:co:dot:uk (":" => "")


Relevant Pages

  • Re: goto
    ... > But the same is true about blanket forbidding of goto. ... > appropriate because the 'cleanup' code would need to be duplicated which ... I'd also bet that there is significant duplication within the class ... If we have to do 3 nested for loops here, ...
    (comp.lang.cpp)
  • Re: Poor style loops?
    ... you certainly could achieve the same effects with goto. ... The question at the time was whether having labelled loops, ... I have never yet encountered code ... > exceptional pigs' breakfasts, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: "Continue" usage
    ... simply to avoid excessive nesting: ... hot and bothered, tightly bound by a strict loop invariant, just to ... because of what happens to the way you think about your loops, ... I think my continue is about the same as my goto usage. ...
    (comp.lang.c)
  • Re: Jumping into block of an if construct
    ... it better have an effect on code generation. ... generated to be different depending on whether the goto was there or ... DO loops are different in many ways. ... such a block is no more well-defined than, for example, jumping into the ...
    (comp.lang.fortran)
  • Re: Simple question!
    ... But there are plenty of circumstances when a goto is better. ... Break your loops into functions and use returns. ... error-cleanup in one spot, to avoid duplicated code. ... Use exceptions, ...
    (microsoft.public.vc.language)