设为首页 加入收藏

TOP

5.10 eva luating Compound Expressions
2013-10-07 15:24:38 来源: 作者: 【 】 浏览:82
Tags:5.10 eva luating Compound Expressions

An expression with two or more operators is a compound expression. In a compound expression, the way in which the operands are grouped to the operators may determine the result of the overall expression. If the operands group in one way, the result differs from what it would be if they grouped another way.

Precedence and associativity determine how the operands are grouped. That is, precedence and associativity determinewhich part of the expression is the operand for each of the operators in the expression. Programmers can override these rules by parenthesizing compound expressions to force a particular grouping.

Precedence specifies how the operands are grouped. It says nothing about the order in which the operands are eva luated. In most cases, operands may be eva luated in whatever order is convenient.

本节内容非常重要,但重要的不是记住各种操作符的优先级与结合性,而是要明白,子表达式求值顺序(order of eva luation)是由编译器自由决定的(除了第5.10.3 节列出的四个例外)。如果表达式有副作用,不同的求值顺序会造成不同的运行结果。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇5.12.2 The Arithmetic Conversio.. 下一篇5.4.3 Compound Assignment Opera..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Sphinx : 高性能SQL (2025-12-24 10:18:11)
·Pandas 性能优化 - (2025-12-24 10:18:08)
·MySQL 索引 - 菜鸟教 (2025-12-24 10:18:06)
·Shell 基本运算符 - (2025-12-24 09:52:56)
·Shell 函数 | 菜鸟教 (2025-12-24 09:52:54)