|
|
|
|
|
by pizza234
1295 days ago
|
|
Passing a reference is semantically different from passing by reference (the latter being a functionality of the language); doing the former (behind the scenes) doesn't imply that the language supports the latter (if one wants to be rigorous, not even C supports pass by reference). The canonical example is a function that swaps the variables passed to a function: a, b = 10, 20
swap_fn(&a, &b)
a == 20 # true
Since the above are primitive data types (ints), in order to make this work, the language needs to generically support passing the address (reference) of the variables. Java¹/Python² etc. are not able to do this; they copy the value of the variable and send it to the function, which will operate on the copy.¹=at least, last time I've checked, which was long ago :) ²=funny to think that at least in Python, one can mess with the global register of the variables, and actually accomplish that |
|