Re: with entry and goto statement

new topic     » goto parent     » topic index » view thread      » older message » newer message
JoKeR said...

... break and loops ...

<snip>

Euphoria is amongst the best (dare I say) with this. I think by break, you mean exit. exit alone always exits from the containing loop. You can, however, have labels:

while 1 label "for-ever" do 
    for i = 1 to length(families) label "each-family" do 
        sequence children = families[i][CHILDREN] 
        for j = 1 to length(children) label "each-child" do 
            if equal(children[j][NAME], "John Doe") then 
                exit -- exits the containing loop, 'each-child' 
            elsif equal(children[j][NAME], "Jane Doe") then 
                exit "each-family" -- exits from the 'each-family' loop 
            elsif equal(children[j][NAME], "Jeff Doe") then 
                exit "for-ever" -- exit all three loops 
            end if 
        end for 
    end for 
end while 

Now, as you say, poorly written, break, exit, continue and retry can all make some terrible code. They are powerful when used correctly and a virtual disaster when poorly written.

Jeremy

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

Search



Quick Links

User menu

Not signed in.

Misc Menu