Re: New switch/case idea

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

I am failing to detect the logic in this discussion.

switch x -- x = 1, let's say 
   case 1 : print "one" 
   case 2 : print "two" 

Why on earth would anyone EVER expect this to print "onetwo", when x = 1?

Can anyone show me a justification for this? Or any example where some other construct wouldn't do the same thing in a clearer way? Or have I simply misread some posts and don't understand?

It's NOT a logical switch, it's a closeted goto stack.

You haveto add "break" on each line.

switch x -- x = 1, let's say 
   case 1 : print "one" break 
   case 2 : print "two" break 

Sorry, Irv, i asked for goto, and sure enough, we got spagetti code from someone. Just chalk this up to "it works like this for historical C reasons" which have nothing to do with reading the source like it was a natural language. It does what it was designed to do: be a stack of goto targets, not a stack of if-thens evaluations. If it doesn't work like you want, make an if-then stack and add a goto "endofstack" to shortcut evaluation. Or, errr, no, we don't have OOEU's eval yet(?) so we cannot goto the value we seek to execute upon it being so. <cough>

useless

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

Search



Quick Links

User menu

Not signed in.

Misc Menu