Re: I miss loop



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 out
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?
The meaning of "continue" is to start the *next* iteration
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)


.



Relevant Pages

  • 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: Iteration in lisp
    ... state machine is just a tagbody and goto. ... But if you need to change the state-transition-matrix in the middle ... loop and either table-driven or separate-functions for defining the ... (tagbody state1 (trace-state1 aux) ...
    (comp.lang.lisp)
  • Re: COBOL aint quite dead - yet !
    ... of control there is nothing wrong with goto. ... The loop is entirely abstracted away. ... Then we have well-formed loops with a single invariant and a looping ...
    (comp.lang.cobol)
  • 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)

Quantcast