Re: how do people feel about exit function from loop



"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23gz9ZCvzHHA.5484@xxxxxxxxxxxxxxxxxxxxxxx
What you're trying to do there is find situations that are suited to not
using exit for.

That's usually how one makes a point.

That's true although I think it's bending the truth a little. If 1% of
examples are suited to exit for and those cases are used to make a point
then you are using a statistical outlyer as if it is the norm.

Only to someone who's not used to that coding style. For myself, I find
it no more or less readable either way. I just don't necessarily know
where my exit points are when using Exit For; when not using it, however,
I know that any code not bracketed by If's and the like WILL run for each
iteration until the conditions are satisfied.

I don't think there's any question the OPs code was less readable without
the exit for.

The only thing that made it more difficult to read for me was the length
of his variable names.

And the extra lines of code. Also with the exit for it is clear that he
wishes to exit the loop and the condition has been satisfied. Without it
that is less clear.

At least one benefit was listed above. As for being difficult to write
and maintain in more complex loops, I generally don't find it makes any
difference whatsoever. You get the same one or two extra lines of
overhead code due to the difference in style, and the rest of your loop
stays the same.

Depends on the complexity of the loop. If used to avoid using exit for and
do know how many hoops need to be jumped through. Sometimes it is quite
extensive.

By the same token, one who's even more immersed in structured programming
than I am might well find it more difficult to figure out what's going on
with the Exit For strategy.

I doubt that at all. It's about as clear as it can get, if a certain
condition is met we exit.

When you get right down to it, pretty much any argument either of us makes
for or against can be applied in reverse as well.

Not really, exit for definately uses less code as one example.

The simple fact is that some people don't like one method or the other, as
it offends their sensibilities, but in reality, there's points for and
against each method.

I really don't see any advantages of not using something that I consider
very useful.

Michael


.



Relevant Pages

  • Re: Infinite Loops and Explicit Exits
    ... > CS> One of these proposals relaxes the current restriction that an EXIT ... > termination of the loop is not visible at that point. ... > terminating condition is visible in that context. ... > You now want to allow this remote procedure, ...
    (comp.lang.cobol)
  • Re: Houston-related rants was Re: forced merges/inside lane merges/AASHTO "tapered merges"
    ... >> Are you sure about the North Loop and I-45? ... >> in particular the westbound exit for Fondren/Gessner. ... How could HCTRA put an exit ramp for eastbound ... and the West Houston Center Blvd exit still shows Old Westheimer ...
    (misc.transport.road)
  • Re: Exit Do
    ... I've been instructed by a dot net / asp programmer that Exit Do is ... I am using nested loops and need to exit out of one loop into ... If Some Reason to stop loop then Exit Do ... Code Stage B ...
    (microsoft.public.scripting.vbscript)
  • Re: Exit Do
    ... I've been instructed by a dot net / asp programmer that Exit Do is ... I am using nested loops and need to exit out of one loop into ... Code Stage B ... likely to lead to bugs and readability problems. ...
    (microsoft.public.scripting.vbscript)
  • Re: Infinite Loops and Explicit Exits
    ... CS> There are cases in which EXIT PERFORM is, I think, clearer than GO TO ... procedure-name-1 SECTION. ... repetition in the main loop statement is being overrun by some minor ... particularly when the requirements of elegance ...
    (comp.lang.cobol)