[...]
Under normal circumstances, one doesn't mess with the count idx. It's a
best programming practice that's used by many.
That's true...it's generally bad form to modify a for() loop index outside
the for() statement. No one's disagreed with that.
Most use another variable an indirect method to control the loop, if
they need a way of terminating out of the loop based on the iteration
count.
Well, it is fairly common to use a different looping construct, such as
"while() { }" or "do { } while ()", when one intends for the looping
condition to be adjusting in non-linear ways inside the loop. It's not
that one doesn't modify a loop control variable from within the loop, it's
just that one doesn't normally do it with a for() loop.
So your way works, big deal. Your way would simply not be the way I
would do it. I would never let your way come through a code review if
you were setting in front of me.
That's fine. If you are in the position to impose your own requirements
on someone else's code, you're free to come up with whatever rules you
like. And in fact, I would probably strongly urge someone to change the
loop if I saw the same thing.
Still, no one's disagreed with the concern that the loop is poorly
formed. So your assertion here is not relevant.
It's a bad habit a lazy habit of programming, that could lead to trouble
in the long run in other areas where you worked a project.
Again, no one disagreed with this.
I would never directly start controlling the idx counter of a loop. the
way you're doing it.
Again, no one disagreed with this.
By an indirect method of controlling the count to control the loop, yes.
Your way should never hit the light of day IMHO. Is it wrong, no it's
not wrong. Is it a best practice, no it's not a best practice either.
That's just the way I was taught.
All of the above, no one has disagreed with. All of those assertions are
preaching to the choir and irrelevant to your original claim.
So why did you leave out your original claim, that the loop would blow
up? Is it possible that you've seen the error of your ways and realized
that the loop will not in fact blow up? Why not just admit it?
This will be my last post on this subject, because I am through with you
and anybody else that needs to make a comment. There will not be a
return reply. It won't be read by me, because I am moving on.
Cool. I love getting the last word. Another one of those pesky
personality defects I've got.
Pete