DEV Community

Discussion on: Why use pointers at all.

 
jessekphillips profile image
Jesse Phillips

No, that is written in the spec meaning they can use "reference" to mean reference value. Reference is just an alias to reference value. Like

"The values of a reference type are references to objects."

It doesn't mean that "reference value" means "a reference" in the sense of other languages, such as C++.

But now you are doing what you told me not to do. That is the specification of a different language not for Java.

My only disagreement is about introducing 'object references' or claiming that there is 'pass by reference' -- these exist in neither language.

"All interactions with objects and array is by reference, much like pointers in C."

I had not made reference to either of those things, yet you did take issue with my statement

If that statement means objects are pass by reference. Then I need to defend that Java has it. If it does not, then why do you take such great efforts to disagree with it?

Thread Thread
 
pentacular profile image
pentacular

It's trivial to show that pass by reference doesn't occur in Java, since changes to the parameter are independent of changes to the argument.

Once you understand that, it should be clear that the "reference value" is not the object that it refers to.

Which means that passing a "reference value" is not passing the object is refers to -- it just passes a means by which to interact with the object it refers to.

Thread Thread
 
jessekphillips profile image
Jesse Phillips

passing a "reference value" is not passing the object is refers to

This is what I have been saying. The object is not passed. A reference is passed and that reference, points to an object.

Thread Thread
 
adam_cyclones profile image
Adam Crockett 🌀

This is impressively long. I feel like you have both made important connection, perhaps you should make a post together 😊 certainly a lot to digest here.