12.3.3.24 || expressions
来源:互联网 发布:同城送货软件 编辑:程序博客网 时间:2024/04/27 22:56
12.3.3.24 || expressions
For an expression expr of the form expr-first || expr-second:
?The definite assignment state of v before expr-first is the same as the
definite assignment state of v
before expr.
?The definite assignment state of v before expr-second is definitely
assigned if the state of v after
expr-first is either definitely assigned or .definitely assigned after
false expression.. Otherwise, it is
not definitely assigned.
?The definite assignment statement of v after expr is determined by:
o If the state of v after expr-first is definitely assigned, then the state
of v after expr is
definitely assigned.
o Otherwise, if the state of v after expr-second is definitely assigned,
and the state of v after
expr-first is .definitely assigned after true expression., then the state
of v after expr is
definitely assigned.
Chapter 12 Variables
111
o Otherwise, if the state of v after expr-second is definitely assigned or
.definitely assigned
after false expression., then the state of v after expr is .definitely
assigned after false
expression..
o Otherwise, if the state of v after expr-first is .definitely assigned
after true expression., and
the state of v after expr-second is .definitely assigned after true
expression., then the state
of v after expr is .definitely assigned after true expression..
o Otherwise, the state of v after expr is not definitely assigned.
[Example: In the example
class A
{
static void G(int x, int y) {
int i;
if (x >= 0 || (i = y) >= 0) {
// i not definitely assigned
}
else {
// i definitely assigned
}
// i not definitely assigned
}
}
the variable i is considered definitely assigned in one of the embedded
statements of an if statement but not
in the other. In the if statement in method G, the variable i is definitely
assigned in the second embedded
statement because execution of the expression (i = y) always precedes
execution of this embedded
statement. In contrast, the variable i is not definitely assigned in the
first embedded statement, since
x >= 0 might have tested true, resulting in the variable i抯 being
unassigned. end example]
For an expression expr of the form expr-first || expr-second:
?The definite assignment state of v before expr-first is the same as the
definite assignment state of v
before expr.
?The definite assignment state of v before expr-second is definitely
assigned if the state of v after
expr-first is either definitely assigned or .definitely assigned after
false expression.. Otherwise, it is
not definitely assigned.
?The definite assignment statement of v after expr is determined by:
o If the state of v after expr-first is definitely assigned, then the state
of v after expr is
definitely assigned.
o Otherwise, if the state of v after expr-second is definitely assigned,
and the state of v after
expr-first is .definitely assigned after true expression., then the state
of v after expr is
definitely assigned.
Chapter 12 Variables
111
o Otherwise, if the state of v after expr-second is definitely assigned or
.definitely assigned
after false expression., then the state of v after expr is .definitely
assigned after false
expression..
o Otherwise, if the state of v after expr-first is .definitely assigned
after true expression., and
the state of v after expr-second is .definitely assigned after true
expression., then the state
of v after expr is .definitely assigned after true expression..
o Otherwise, the state of v after expr is not definitely assigned.
[Example: In the example
class A
{
static void G(int x, int y) {
int i;
if (x >= 0 || (i = y) >= 0) {
// i not definitely assigned
}
else {
// i definitely assigned
}
// i not definitely assigned
}
}
the variable i is considered definitely assigned in one of the embedded
statements of an if statement but not
in the other. In the if statement in method G, the variable i is definitely
assigned in the second embedded
statement because execution of the expression (i = y) always precedes
execution of this embedded
statement. In contrast, the variable i is not definitely assigned in the
first embedded statement, since
x >= 0 might have tested true, resulting in the variable i抯 being
unassigned. end example]
- 12.3.3.24 || expressions
- 12.3.3.23 && expressions
- 12.3.3.25 ! expressions
- 12.3.3.26 ?: expressions
- Expressions
- Expressions
- Expressions
- 12.3.3.20 General rules for expressions with embedded expressions
- 12.3.3.21 Invocation expressions and object creation expressions
- 12.3.3.22 Simple assignment expressions
- Regular Expressions
- Validating Expressions
- 8.5 Expressions
- 14. Expressions
- Ragular expressions.
- 6.5 Expressions
- Regular Expressions
- CURSOR Expressions
- 12.3.3.22 Simple assignment expressions
- TFS beta版真是烦人
- LINUX系统CentOS介绍及安装文档
- 手把手教你捕获数据包
- 12.3.3.23 && expressions
- 12.3.3.24 || expressions
- 12.3.3.25 ! expressions
- 12.3.3.26 ?: expressions
- 12.4 Variable references
- Model Maker上手指南
- 进程退出前删除自身EXE程序
- 12.5 Atomicity of variable references
- 全球第一中文编程语言诞生了
- GoF的Abstract factory的c/c++实现