I read the book "Programming Languages", learning something about the passage of parameters, and there was doubt about the call by value / restoration.
I understand how this works in general cases, but consider this case:
procedure P(x, y, i){
x[i]=y[5-i]
if( i<4 ) P(x, y, i+1)
}
procedure main(){
a=(1, 2, 3, 4, 5)
P(a, a, 0)
}
After calling P (a, a, 0), a local copy of both "a" is created (allows you to call them a_0 and a_1). But when he returns, a_0 and a_1 will have different meanings.
a_0 = (5, 4, 3, 2, 5)
a_1 = (1, 2, 3, 4, 5)
Therefore, when he tries to restore "a" with a new value ... we find two different possibilities. What will be here? Will it be restored first by a_0 and overwritten by a_1? What would be the meaning of "a" after P (a, a, 0)?
, - , .
.