Re: how do people feel about exit function from loop



"greg" <greg@xxxxxxxxxx> wrote in message
news:%23jsxyFXzHHA.4844@xxxxxxxxxxxxxxxxxxxxxxx

In general,
How do people feel about using exit function from inside of a loop?
Is it bad practice?
So for example. The same code written 2 ways. Is the #1 bad code?
thanks

Here we go again. :-) To add to what other's have said, quite often exit for
or exit function is considered bad because it is likened to Goto. Yes, Goto
is bad but it is bad because it has the ability to ENTER a loop when it
shouldn't. It is not really considered as bad if it is used to to exit a
loop.

I would also repeat what other's have said, that if you find yourself making
code more complicated and less readable to avoid an exit for or exit
function (like you have here) then should should probably reconsider. Number
2 is significantly less readable.

Michaek


.



Relevant Pages

  • Re: Is David Fenton right about error handling? (re-post?)
    ... > Error Goto 0 a proper termination. ... after the Exit Function. ... Clears all property settings of the Err object. ... Exit Sub, Exit Function, Exit Property ...
    (comp.databases.ms-access)
  • 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: 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)

Loading