Re: Is Euphoria a Hobby language?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Wed, 24 Nov 2004 01:29:58 -0800, Alexander Toresson
<guest at rapideuphoria.com> wrote:
> posted by: Alexander Toresson <toressonodakra at swipnet.se>
> 
> cklester wrote:
> > > Or break out of multiple levels of loop without slowdown.
> > ?
> 
> Replace:
> 
> integer flag
> 
> flag = 0
> 
> for a = 1 to 10 do
>     for b = 1 to 10 do
>         if b = 5 then flag = 1 exit end if
>     end for
>     if flag then exit end if
> end for
> 
> With a better way of doing it.

Exactly. The work-around is much slower (because it has to run the if
statement each iteration), and needs an extra variable.

I think the best and simple enhancement would be to allow this:

for a = 1 to 10 do
    for b = 1 to 10 do
        if b = 5 then 
           exit a --exit the for loop that uses 'a'
        end if
    end for
end for

or for while loops:

while 1 as a do --(as a is optional)
     for b = 1 to length(somevar) do
              if not somevar[b] then
                     exit a
              end if
     end for
end while

-- 
MrTrick

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu