Re: New Switch Idea

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

My thoughts? I personally like the idea and with the "smart switch" ability, I would prefer that the default be without fallthru. That would seem to hit the largest use of switch. Here's an example of how an undecorated switch would work if we had smart switch and the default of without fallthru:

integer X = 2 
switch X do 
  case 1: 
  case 2: 
  case 3: 
  case 4: 
  case 5: 
    puts(1, "5 or less\n") 
  case 6: 
  case 7: 
  case 8: 
  case 9: 
  case 10: 
    puts(1, "at least 6 no more than 10\n") 
  case else 
    puts(1, "less than zero or greater than 10\n") 
end switch 
 
-- output: 
-- 5 or less 

Jeremy

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

Search



Quick Links

User menu

Not signed in.

Misc Menu