Re: how do people feel about exit function from loop
- From: "Michael C" <nospam@xxxxxxxxxx>
- Date: Mon, 30 Jul 2007 14:58:57 +1000
"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:%23ebF9Mm0HHA.1204@xxxxxxxxxxxxxxxxxxxxxxx
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.
Whatever you are used to that is simply more difficult to read than a for
loop. A for loop is very clear.
Ummm...I hope you only need to read the first three. :)
You need to read all 4 to determine i is not modified elsewhere, ie you have
to read to the end of the loop statement.
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 don't know how you can say that. A for loop is as clear as it gets.
Anything else is simply less clear.
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. :-)
Have I not stressed at least 100 times ALL ELSE BEING EQUAL. I knew right at
the start you'd take off with the less code is better thing and find
examples where it is obviously not. That does not mean in this case that
less code is not 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.
When I say all else is equal I mean the loop does that same thing and we
have not broken any general programming rules (such as goto is best
avoided).
And now we get back to why Goto is "silly" when Exit is not.
Because goto can jump into loops and jump all over the place. Exit is NOT
goto.
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.
Not really, make a mistake with that goto and you don't get warned. You
could easily jump across 3 loops and end up inside a different loop and not
be warned by the compiler. This is a BIG reason for not using goto, possibly
THE reason. Compiler warnings/errors are a big plus.
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>)
I don't consider this to even be an issue worthy of mention. I think you're
just trying very hard to find arguements against exit for that don't exist.
Michael
.
- Follow-Ups:
- Re: how do people feel about exit function from loop
- From: Robert Morley
- Re: how do people feel about exit function from loop
- References:
- how do people feel about exit function from loop
- From: greg
- Re: how do people feel about exit function from loop
- From: Ken Halter
- Re: how do people feel about exit function from loop
- From: Jan Hyde (VB MVP)
- Re: how do people feel about exit function from loop
- From: Steve Gerrard
- Re: how do people feel about exit function from loop
- From: Michael C
- Re: how do people feel about exit function from loop
- From: Robert Morley
- Re: how do people feel about exit function from loop
- From: Michael C
- Re: how do people feel about exit function from loop
- From: Robert Morley
- Re: how do people feel about exit function from loop
- From: Michael C
- Re: how do people feel about exit function from loop
- From: Robert Morley
- Re: how do people feel about exit function from loop
- From: Michael C
- Re: how do people feel about exit function from loop
- From: Robert Morley
- Re: how do people feel about exit function from loop
- From: Michael C
- Re: how do people feel about exit function from loop
- From: Robert Morley
- Re: how do people feel about exit function from loop
- From: Michael C
- Re: how do people feel about exit function from loop
- From: Robert Morley
- how do people feel about exit function from loop
- Prev by Date: Is there any size limit regarding .ini file?
- Next by Date: Re: how do people feel about exit function from loop
- Previous by thread: Re: how do people feel about exit function from loop
- Next by thread: Re: how do people feel about exit function from loop
- Index(es):
Relevant Pages
|
Loading