【发布时间】:2013-06-04 21:32:49
【问题描述】:
考虑以下伪代码(与语言无关):
int f(reference int y) {
y++;
return 2;
}
int v = 1;
v += f(v);
当函数f在评估v += f(v)时改变y(即v),是v的原始值“冻结”并变为v“丢失”?
v += f(v); // Compute the address of v (l-value)
// Evaluate v (1)
// Execute f(v), which returns 2
// Store 1 + 2
printf(v); // 3
【问题讨论】:
标签: language-agnostic programming-languages operators pseudocode compound-assignment