View Single Post
  #5  
Old 01-23-2007, 01:52 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
Quote:
Originally Posted by JkWhoSaysNi View Post
Why? It's only like a 2 line case statement.

It's much neater than either a case statement or if / else and has the same result.
You sacrifice code clarity for a few less characters. if(condition) this; else that; makes more sense than (condition? this : that) when you glance at your code. You shouldn't have to comment code that documents itself either.

There is a reason why ?: is considered an operator and not flow control. Because it isn't.

In reference to your original question, the compiler probably skips over statements that don't make sense like 1+1; Why waste CPU resources on some stand alone expression whose computed value is never used? The assumption the compiler makes is that (?:) is used for expressions, not for program flow. To act otherwise is dangerous, especially if the nature of the compiler changes, it may break your code.
__________________

subliminal message: 1+1=3

Last edited by Falcor; 01-23-2007 at 01:53 AM.. Reason: smiles.
Reply With Quote