On Feb 18, 2006, at 2:37 PM, Eric Chatonet wrote:

switch
  case x < 100
  case  x > 500
  case  x > 200 and x < 400
    <statements>
    break
  default
    <other statements>
end switch

With a conditional structure you would write:

if x < 100 or x > 500 or (x > 200 and x < 400) then
  <statements>
else
 <other statements>
end if

The first formulation seems much more clear to me :-)

To me no. The if statement seems all too clear. I think this greatly depends on what past experiences a programmer may have had.

I spent years programming in Visual DialogScript on Windows, and there were no switch/case in the syntax (It's an odd syntax in the first place). The above would look like this:

If @not(@greater(%x,100))@greater(%x,500)@both(@greater(%x,200),@not (@greater(%x,400)))
  <statements>
else
  <statements>
end

So you can see how one could become rather used to a certain flow or way of things. It becomes second nature. I haven't programmed in Visual DialogScript since last summer and still instinctively I was able to toss together the if structure there. And of course, it carries over when moving to another language. That and one other thing, is that you can always count on another language having "IF/ ELSE/END" in it's syntax, so it's kind of a universal attribute for programming languages.

Not that the switch/case isn't more logical or vice versa.

-Garrett

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to