Re: New switch/case idea

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

How about single colon for continue and double colon for break.

The single colon would fall through. When the parser encounters a double colon it would continue until it saw the next case keyword.

This would be easier to parse and eliminates a lot of typing and extra wording and keeps it simple in the Euphoria tradition.

Actually, the new proposed syntax does not use : at all, it uses then, to keep with Euphoria syntax:

switch X do 
    case 1 then 
        ? 1 
    case 2, 3, 4, "John" then 
        ? 2 
end switch 

Jeremy

That's not what I'am talking about thats multiple case not multiple fall through or break.

Bernie, are you even reading Jeremy's responses?

You said "How about single colon for continue and double colon for break." and Jeremy said that we are not actually using colons anymore. So therefore your suggestion can't be taken up.

Here is how you do fall through now ...

  switch X with fallthru do 
     case 1 then 
        ? 1 
        break 
     case 2, 3, 4 then 
        ? 2 
     case 5 then 
        ? 5 
  end switch 

Notice the with fallthru clause. That means that this switch falls through to the next case action until either a break is found or the end switch is found.

In the example above here are the results for various values of X...

X Result Why
1 1 'break' stops the fall thru
2 2 5 no break so case '2' falls thru
3 2 5 no break so case '3' falls thru
4 2 5 no break so case '4' falls thru
5 5 last case
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu