Re: New switch/case idea

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

If the break is not the last statement of the case and if it works as in C language, then break has an effect: it aborts the switch statement immediately.

That should still work in Euphoria too, but it doesn't at the moment. I think this is a bug. To get it to work currently you have to add a label to the break clause...

  switch X label "A" do 
      case 1 then 
      . . . 
         if cond then 
             break "A" 
         end if 

It's not a bug. It's how the break statement works. Originally, break was added to to exit out of an if block. We didn't want to use exit, since code like this is common:

while x do 
    if foo(x) then 
        exit 
    end if 
end while 

Using similar logic, we decided to use break for the switch statement, and keep exit for loops.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu