|
|
|
|
|
by binaryfinery
5672 days ago
|
|
No the real problem is that you fail to understand that Java gets to call these things what ever it likes because language has context. And your example fails to compare apples to apples. In Java Integer is an object, but int is not. You are confusing Java things with C++ things. As you can see, Java is not C++, and so your C++ terms and definitions do not apply here. Thank you for playing. Move along. |
|
This is silly; "pointer" and "reference" both had meanings before Java came along. If Java called pointers "names" instead of "references" it wouldn't mean that its function call semantics were pass-by-name either. And besides; if your argument is that we should use the Java terminology to describe all the aspects of Java under discussion, the fact that the all the Java designers make explicit that the function call semantics pass references as values, not objects as values.
"And your example fails to compare apples to apples. In Java Integer is an object, but int is not. You are confusing Java things with C++ things."
The argument applies if you use int in place of Integer just the same; or if you make a C++ Integer wrapper class analogous to the Java one. Any comparison here will of course be apples to oranges because C++ supports pass by reference and Java does not. The swap function is impossible to write in Java because it requires allowing called functions to change the values viewed in the caller, which is almost the definition of passing arguments by value.
"As you can see, Java is not C++, and so your C++ terms and definitions do not apply here. Thank you for playing. Move along."
Leaving aside the childish and insulting tone, the definition of "pass by reference" has nothing to do with C++; if the code were in perl it would still be pass by reference, because "pass by reference" has a meaning that exists outside of any particular programming language and describes a concept. Java function calls are not part of that concept; "there is exactly one parameter passing mode in Java - pass by value".