Re: I miss loop
- From: cj <cj@xxxxxxxxxxxxx>
- Date: Wed, 15 Mar 2006 16:10:10 -0500
Thanks for all the support. I posted this to Mythran also but I wanted to make sure you saw it as well.
In reviewing some of this just now I see one thing that would need to be considered in choosing goto vs nested loops. 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. I haven't tried but I get the impression from the help that goto can't be used to jump outside a loop (to the line above it) so it could be restarted, hence goto could only be used to go to the first line inside the loop. variables inside the loop would not be refreshed they would be as they existed before the goto was executed. This could be good or it could be bad. Just has to be checked into and considered.
dotNuttah wrote:
cj wrote:.I understand the functionality of continue. I also understand it
doesn't work in VB.Net 2003, right? It does in 2005, right?
I don't know about 2005. ;-)
I understand why goto is not generally a good thing but just because a
command has been frequently misused in the past doesn't make it bad.
I admire Herfried for suggesting goto. It seems like a perfect use.
I've never thought goto was bad. I think that bad use of it is bad. :-D
Still I'm having a hard time using it because other say it's wrong.
It's a real conundrum. There has to be a way that socially acceptable
and personally feels right.
You're the only one that can change your personal perspective on it.
Socially it really depends on who's opinion you're giving value to. I wonder
what would happen if you change your personal perspective to let you use
goto when the situation warrants it, and give it more priority than "social"
opinion. :-))
An outer loop is what I have started with because goto has been out of
my vocabulary since 87. Still I just don't like seeing one loop
inserted inside another just for this functionality. It looks funny
and just seems wrong.
I often use that method but yep, it looks clumsy, clumsy and makes the code
cry out for some decent syntax for this structure. I can't remember where it
was but one language I came across had "break" (or exit loop) and "continue"
with an index. The index was the level of the loop that the break or
continue was applied to. Very handy.
To make the goto easy to use for a reader you have to make it stand out in
the code, else the reader might be hunting all over for it and that can look
clumsy too. Do you have the label in column one or indent it (and hence bury
it, to a degree) in the code which it labels? :-/ A choice of name that says
where to go/look, like "goto bottom_of_loop" helps.
I'll come up with a better way. Something in
the nature subroutines and flags etc.
Aye, it sounds as if the loop body contains enough that a subroutine would
be appropriate anyway, perhaps.
I'll get something that feels better when I get back to work tomorrow.
:-))
dotNuttah wrote:cj wrote:When I'm inside a do while loop sometimes it's necessary to jump outThe meaning of "continue" is to start the *next* iteration
of the loop using exit do. I'm also used to being able to jump back
and begin the loop again. Not sure which language my memories are
of but I think I just said loop somewhere inside the loop and it
immediately jumped back to the start of the loop and began again. I
can't seem to do that in .net. I this functionality available?
immediately and bypass any further code in the loop body. If you
want to continue the current operation then you'd either have an
inner loop or use a goto. If you want to completely restart the loop
then you'd be best enclosing it in an outer loop. You mustn't use
the goto idea for that one. Jumping out of the loop to before the
loop - that should get you those frowns. ;o)
- Follow-Ups:
- Re: I miss loop
- From: Mythran
- Re: I miss loop
- From: cj
- Re: I miss loop
- References:
- I miss loop
- From: cj
- Re: I miss loop
- From: dotNuttah
- Re: I miss loop
- From: cj
- Re: I miss loop
- From: dotNuttah
- I miss loop
- Prev by Date: Re: I miss loop
- Next by Date: Re: Setting Foreground Color Property at Row Level in Datagrid
- Previous by thread: Re: I miss loop
- Next by thread: Re: I miss loop
- Index(es):
Relevant Pages
|