On 10 November 2010 12:21, Mark Wendt <[email protected]> wrote:

> The behavior in short circuit evals is a little
> different than in other evals.  So in this case, with the simple if
> statement - if (new_in && new_in!=start_in), the precendence of the "!="
> doesn't really matter that much.  If the second expression was more complex,
> with other operators, it would make a difference.

I don't think that Kirk was talking about "Short circuit evaluation"
in this sense. I think he was puzzled by what the phrase
"new_in && new_in" was doing. Perhaps he could chime in and clarify.

I disagree about the importance of operator precedence in this case.
If && had a higher precedence than != then the functional behaviour of
that "if" statement would be quite different.

With actual C precedence:
new_in   0  1  0  1
start_in  0  0  1  1
result     0  1  0  0

with && having higher precedence than != (new_in && new_in) becomes an
accidental cast-to-boolean:

new_in   0  1  0  1
start_in  0  0  1  1
result     0  1  1  0

-- 
atp

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to