Talk:Operators in C and C++: Difference between revisions

Content deleted Content added
No edit summary
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 185:
The explanation about parsing "e = a < d ? a++ : a = d" is incorrect. In C, it is not parsed as "(a < d ? a++ : a) = d" but just a syntax error; this is because the standard grammar for the assignment expression is
 
<sourcesyntaxhighlight lang="c">
unary-expression assignment-operator assignment-exression
</syntaxhighlight>
</source>
 
and the conditional expression cannot match to "unary-expression." Most compilers (especially with recursive-descent parsers) modify the grammar by replacing "unary-expression" with "conditional-expression" to avoid back-tracking or look-ahead or to handle errors gracefully, and thereof the syntactic error turns into a semantic one saying that the left operand of "=" or "op=" should be an lvalue. Which is why many people mistake the error for the semantic error. --[[User:Woong.jun|Woong.jun]] ([[User talk:Woong.jun|talk]]) 11:43, 15 March 2010 (UTC)
Line 307:
 
For example:
<sourcesyntaxhighlight lang="c">
void foo (int count)
{
Line 313:
//Now do something here.
}
</syntaxhighlight>
</source>
 
== Notes ==