++a求值,而不会再对子表达式c > d ? ++c : ++d求值了。显然,此表达式中条件操作符的右结合只用于确认左边条件操作符的右操作数,而没有使得右边条件操作符先求值。
四、结束语
虽然C语言表达式种类繁多,但有着相对明确的表达式求值规则,根据求值规则正确分析出表达式的求值顺序有助于激发学生学习的主动性。在教材中照搬C语言标准中序列点的概念势必会增加学习的难度,给初学者提供一个准确且易于理解的概念,不仅不会造成C语言知识点的残缺,而且也为启发式教学提供了可能。
参考文献
[1]黄瑛,胡烈,朱其慎. 序列点——C语言教学的一个普遍盲区[J].电脑知识与技术,2011(3):2105-2106.
[2]国家技术监督局. GB/T 15272-1994 程序设计语言C[S]. 北京:中国标准出版社,2004.
[3]周二强著. C语言内涵教程[M]. 中国铁道出版社,2013:68.
Effect of Sequence Point on Expression eva luation in Language C
Abstract:
The effect of the sequence point on expression eva luation in Language C is analyzed from all new angle of view. The operand in the form of sub-expression located to the left of the operator with sequence point is eva luated before the right operand. This text explains the reason the comma operator, logical AND operator, logical OR operator and ternary conditional operator need sequence points. The role of the sequence point on expression eva luation is discussed by citing examples.
Keywords: sequence point; expression eva luation; language C
?