
L-value and R value
L-value: refer to location, passing by reference.
R-value: refer to the value stored at the location, passing by value.
Reading location on the right and writing to the location on left
Passing by reference and Passing by value
Passing by value
To run g (e):
1, evaluate e to a value v
2, pass a copy of v to g
3, callee changes to copy of v not visible to caller
Passing by reference
To run g (e):
1, evaluate e to an l-value r
2, pass the l-value r to g
3, callee changes via r are visible to caller
Ps: l-value is reference
In c
Array is passing by reference and other is passing by value.
In java
Reference Type is passing by reference and other is passing by value.




近期评论