3 ms·
I don’t see why C++ “references” should have a monopoly on the term “reference," such that a language calling anything else a reference is making an error. C++
by dgreensp 9y ago
I don’t see why C++ “references” should have a monopoly on the term “reference," such that a language calling anything else a reference is making an error. C++ references are actually kind of a weird/unusual language feature that isn’t being taken up by other languages. I don’t see cause for reserving a term for them. Each language can decide what it is going to call a “reference.”
- ohf 9y agoJava references are closer to C++ references than anything else. They're like pointers until you access/call them, at which point they're just objects. C++ references are identical, but the syntax is a bit more explicit. It is a funny language feature to have when you think about it; it just so happens to be useful. References and pointers are distinct in languages that have both (C++), so not mixing the terms between languages is helpful. If Java programmers started referring to their variables as "pointers," because internally, that's more representative of what they are, I'd be a bit irked.
- jholman 9y agoIt's not that other languages don't have references, or that they cannot redefine references. It's that the phrase "pass by reference" is a term of art in compiler design, and all language theorists including those who work on Java agree on what it means, and what it means is the thing the article says it means, and Java doesn't do it. What gets passed by value in Java? Well, sometimes it's a reference-as-Java-means-it! But that reference is always passed by value, never passed by reference.