[erlang-questions] call by value
Richard O'Keefe
ok@REDACTED
Mon May 23 03:33:40 CEST 2011
On 20/05/2011, at 11:59 PM, Martin Dimitrov wrote:
>
>> but for "values" that are (references to) linked structures,
>> no copying is done.
>>
> If you are talking about Java, isn't this copy-by-reference?
I've never seen the term "copy-by-reference" before,
so I can't tell. It certainly isn't PASS by reference.
void incr(int &x) {
x++;
}
int main(void) {
int b = 2;
incr(b);
cout << b << endl;
}
in C++ (a) uses pass by reference, and (b) prints 3.
You cannot do that in Java.
Java has pass by value and ONLY pass by value.
Some of those values are (perhaps confusingly)
called "object references" (in practice they are
almost always just plain pointers, something
Java is, again misleadingly, said not to have).,
More information about the erlang-questions
mailing list