RE: "continue/next" for "loop"

From: amado.alves (amado.alves_at_netcabo.pt)
Date: 11/03/03


Date: Mon, 3 Nov 2003 15:44:43 -0000
To: <comp.lang.ada@ada-france.org>


"Sometimes I use exceptions..."

I remember some people are against using exceptions for control flow. I think this even appears in some coding standards.

So, as other have said, the goto might be appropriate.

Yet another way is to structure the code more, i.e. put the crucial sequences of statements inside (local) procedures, and then call the procedures at the appropriate points.

Of course you may have to parametrize the procedures to pass the values of the loop control variables.

Come to think of it, this is probably how I do it most of the times. I seem to remember having really long procedure names...



Relevant Pages

  • Re: Using exceptions for early exit
    ... > would expect that people reading the code would /not/ expect exceptions to be ... Nor is the shape of the control flow a problem. ... My objections to control-flow-by-exception are twofold. ... First, there's efficiency. ...
    (comp.lang.java.programmer)
  • Re: Advice on handling multiple return values?
    ... I've found control flow difficult to ... understand when looking at code which used exceptions to handle ... errors (like errors on opening files, etc.), therefore you have to ... handle them for the most part, possibly in outer functions, thus ...
    (comp.lang.scheme)
  • Re: Advice on handling multiple return values?
    ... I recommend using exceptions for errors as well. ... "exceptional" control flow, both indicate unexpected situations. ... control flow that no longer can assume correct behaviour. ... In practice error codes are easily ignored, ...
    (comp.lang.scheme)
  • Re: Advice on handling multiple return values?
    ... The whole point of exceptions is not to ... I've found control flow difficult to ... I now try to actually remove checked exception clauses in ... rewrapped them into the next level's checked exception type and rethrew. ...
    (comp.lang.scheme)
  • Re: Real life cost of using exceptions for control flow?
    ... I'm working with an app that uses exceptions for control flow. ... I would not worry about the cost of throwing/catching exception (although is ... because it is polluted by catch clauses that deal with the "normal" logic. ...
    (microsoft.public.dotnet.framework.performance)