Re: how do people feel about exit function from loop



I doubt we are that different.

If we weren't, we wouldn't get into these pointless debates. :-)

I find that significantly less clear than a for loop.

Which comes back to what I've been saying all along...I'm used to the style,
and I have no problems with it at all.

You need to read all 4 lines to determine it counts down from 100 and then
think if it counts to 1 or 0.

Ummm...I hope you only need to read the first three. :) And as to that,
having the 100 and the decrement on separate standalone lines makes them
stand out to me far better than a For Next loop for that, but that's really
neither here nor there, as obviously For Next loops are common enough that I
can usually scan through them just about as fast. But reading only one
line, the line that starts the loop, I know ALL the exit conditions for the
loop (assuming that someone isn't using an Exit inside it, which I at least
know for my own code won't be the case).

I've said this many times but here goes again. LESS CODE IS NOT ALWAYS
BETTER.

Actually, mostly you've been stressing that less code *is* better. :-)

If all else is equal then it is something that can be better.

If you dislike Exit statements and the style of programming it engenders
(multiple exit points), then I'd say all else is NOT equal.

Certainly any good programmer will try to keep the number of lines down
without going overboard and using silly ideas like goto.

And now we get back to why Goto is "silly" when Exit is not. Properly used,
Goto can be a perfectly legitimate construct. (Again, it's one I haven't
used since the days of Q-Basic, but for the sake of argument....) Yes, it
has the possibility of being improperly used, but so does nearly everything
in VB. Used as a simple loop, instead of being used to create spaghetti
code, it's technically on a level with any other method of looping.

That's true although I doubt anyone would be downgrading their language.

I don't claim to be an expert, but I suspect there are at least some modern
languages that don't support it. Others would have to comment on that,
though, as I have knowledge of only a few languages. Last I heard, Break
was still considered "a bad thing" (as much so as Goto) in Pascal variants,
but that may have changed over the years. Regardless of that fact, at least
some structured programming adherents still dislike it (and don't tell me
you've never come across any, cuz you've come across me! <g>)



Rob


.



Relevant Pages

  • 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: 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)
  • Re: Looking for a way to convert dec to bin
    ... It's set in stone now for vb but yes, many languages won't work. ... designed languages the loop var is out of scope anyway. ... This loop will probably never exit because b is always 255 or less. ... Generally if I need the index then I won't use foreach. ...
    (microsoft.public.vb.general.discussion)
  • Re: "continue/next" for "loop"
    ... Ada 200X. ... goto exit; -- exit innermost enclosing loop. ...
    (comp.lang.ada)
  • Re: FORTRAN "Source Code to Flow Chart Converter" Available
    ... >> can EXIT a loop, possibly using a labelled DO loop when loops are ... so one need not GOTO the last line of a procedure ... >> to exit it. ... > the type of person who, if a STAT or IOSTAT specifier exists, I check it. ...
    (comp.lang.fortran)