1. exiting out of nested loops

> Kat,
> still wants "goto" in Eu, then she can "exit" out of any loop with the one
> command, to a properly well defined and easily read local target.

yes, this is real problem, because you have to add flags and check them
every time. (Goto's really aren't that bad as I said once.)

one good solution, i think, would be this way:

while 1 do
    while 1 do
        exit --exit first loop
        exit --exit parent loop
    end while
end while


--now you have to do it this way:

while 1 do
    while 1 do
        doExit=true--set flag
        exit
    end while

    --we have to check this flag *every time*, it eats up time
    if doExit=true then
        exit
    end if
end while

Good idea, huh? smile i really like it, simple and fast.

new topic     » topic index » view message » categorize

2. Re: exiting out of nested loops

On Fri, 19 Jan 2001, Tone =A9koda wrote:
>> > Kat,
>> > still wants "goto" in Eu, then she can "exit" out of any loop with t=
he one
>> > command, to a properly well defined and easily read local target.
>>=20
>> yes, this is real problem, because you have to add flags and check the=
m
>> every time. (Goto's really aren't that bad as I said once.)
>>=20
>> one good solution, i think, would be this way:
>>=20
>> while 1 do
>>     while 1 do
>>         exit --exit first loop
>>         exit --exit parent loop
>>     end while
>> end while

Your idea is ok but would Euphoria not INSTANTLY break out of the nested
while loop. The second it saw a "exit" Eu would bust out of the loop and =
not
bother to look at the second one. I know its possible to change Euphoria =
so
it would read both but i dont think that EXCEPTIONS to rules in a languag=
e are
any good, one rule should apply to all, without exceptions here and there.

my 2cents

--=20
evil, corruption and bad taste
^[cense]


>> --now you have to do it this way:
>>=20
>> while 1 do
>>     while 1 do
>>         doExit=3Dtrue--set flag
>>         exit
>>     end while
>>=20
>>     --we have to check this flag *every time*, it eats up time
>>     if doExit=3Dtrue then
>>         exit
>>     end if
>> end while
>>=20
>> Good idea, huh? smile i really like it, simple and fast.

new topic     » goto parent     » topic index » view message » categorize

3. Re: exiting out of nested loops

>From: cEnsE <cense at MAIL.RU>


>> while 1 do
>>     while 1 do
>>         exit --exit first loop
>>         exit --exit parent loop
>>     end while
>> end while

>Your idea is ok but would Euphoria not INSTANTLY break out of the >nested
>while loop. The second it saw a "exit" Eu would bust out of the loop and
>not
>bother to look at the second one.

then maybe exit(2) would be better, exit(1)=exit, but i like syntax more
with prevoius, two exit statements followed.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu