Re: Labeled Loops?
> On 12 May 2008 at 17:01, Jeremy Cowgar wrote (maybe snipped):
> Hm... what about:
>
> }}}
<eucode>
> for a = 1 to 10 label "top" do
> for b = 1 to 10 label "mid" do
> while 1 do
> if b = 3 then exit "top" end if
> if a = 2 then continue "mid" end if
> end while
> end for
> end for
> </eucode>
{{{
>
I agree if all we need is "breaking" loop laces. But if I need to go
to "Far Far Away" then probably we'd need "goto". The problem I see
is that in an Euphorian way, labels should (must?) be declared prior
to use, just like variables, so this would be a problem in most
cases.
Though I never need it before (since those times of BASIC and COBOL),
there are times I need to re-think a large part of the code so I
don't get stuck on lace-structured code. Goto and gosub would get me
out of the trouble in a snap, but my code would look (and would be)
so ugly and (probably) so difficult to maintain that I can't see the
real benefit of it. But this is just me. ;)
And Jeremy, just trying to understand the concept of "exit" and
"continue" on the example above: continue "mid" exits the while loop
and goes to next iteration of "mid" for...end for loop. OTOH, exit
"top" exits the whole thing and code will continue execution after
"top" for...end for loop, if any. Did I get it right? Sorry, but I'm
getting these nouveaut=E9s quite slowly. :)
Best,
Euler
--
_
_| euler f german
_| sete lagoas, mg, brazil
_| efgerman{AT}gmail{DOT}com
|
Not Categorized, Please Help
|
|