A
Arved Sandstrom
Andreas Leitgeb said:By the way, this is also true for "reference" itself. They also have
to learn that what Java calls a reference wouldn't be called that way
in other languages, for exactly the reasons you wrote (null allowed,
assignment-semantics).
Hey, one's mind can get bent in new and wonderful ways. When I encountered
nullable value types in C# there's no question but that I scratched my head
a bit, particularly since before that I kept on reading statements like "a
struct instance cannot be null". Finding out that I could circumvent this
little annoyance by having nullable structs was eye-opening. Admittedly
a very handy feature.
Why is it ok, to talk of references in Java, but have an entirely
different meaning of "reference" in mind in context of the phrase
"pass by reference"?
Because one "reference" is an object reference, and the other means passing
the address of something, but since we're not passing the address of the
reference...
I deduced my liberty to "redefine" "pass by ref" from Java's liberty
to redefine "reference" in the first place. My redefinition of
it was coined on java's vocabulary: Objects are not passed directly
(as possible in C++, where the whole structure of the object gets
dumped on the stack), but "through use of (Java-)references".
This is natural language as I understand it.
Natural language (computer science, but not language-specific) is that a
reference contains information referring to data stored elsewhere (the
referent). This may be accomplished with raw addresses or otherwise. AFAIK
Java and C# use handles (pointers to pointers), something quite familiar to
anyone who did lots of Macintosh programming back in the day. I stand to be
corrected if Java object references are not handles.
AHS