我们都会混用一些术语,没有人喜欢罗罗嗦嗦.
如The Java Programming Language,混用了objects and references(to objects),
Thinking in Java混用了什么?identifier (you manipulate) is (actually a) “reference” (to an object.)
关于Thinking in Java,假设世界上没有C++,只有C和fortran语言,我不知道他说的那些东西那里准确.
Pass an object reference to the method.和pass by reference还有多大区别呢?
如果你把所有的接口都认为是Java的接口,你就知道"接口和实现分离"是多么难以解释/理解.pass by reference是计算机语言中的一般术语,不是Java的.
[最后,没有必要强迫别人接受你的思想和概念.用java设计好程序比什么都强.]
常常听人说基础很重要,假设pass by reference这是一个基础问题,不存在强迫别人接受谁的思想和概念,它不包含新的概念,不过是在"when it makes a difference." We are careful about this distinction .
[Quote=引用 23 楼 yqj2065 的回复:]
21楼:
谢谢。
《java编程思想》(第27页),在它的第一版我就看见这个错误,还没有改过来,真硬气。
[/Quote]
我想这也是错怪了Thinking in Java了,我看的是第四版,里面有说明:
Although you treat everything as an object, the identifier you manipulate is actually a “reference”
to an object.
对这句话有注释:
1 This can be a flashpoint. There are those who say, “Clearly, it’s a pointer,” but this presumes an underlying
implementation. Also, Java references are much more akin to C++ references than to pointers in their syntax. In
the 1st edition of this book, I chose to invent a new term, “handle,” because C++ references and Java references
have some important differences. I was coming out of C++ and did not want to confuse the C++ programmers
whom I assumed would be the largest audience for Java. In the 2nd edition, I decided that “reference” was the
more commonly used term, and that anyone changing from C++ would have a lot more to cope with than the
terminology of references, so they might as well jump in with both feet. However, there are people who disagree
even with the term “reference.” I read in one book where it was “completely wrong to say that Java supports pass
by reference,” because Java object identifiers (according to that author) are actually “object references.” And (he
goes on) everything is actually pass by value. So you’re not passing by reference, you’re “passing an object
reference by value.” One could argue for the precision of such convoluted explanations, but I think my approach
simplifies the understanding of the concept without hurting anything (well, the language lawyers may claim that
I’m lying to you, but I’ll say that I’m providing an appropriate abstraction).
The Java Programming Language虽然强调pass by value,但是也支持不精确的表达,要不你每说一句话都强调,岂不是太累了.
1.7.1. Creating Objects
Most of the time, you can be imprecise in the distinction between actual objects and references to objects. You can say, "Pass the object to the method" when you really mean "Pass an object reference to the method." We are careful about this distinction only when it makes a difference. Most of the time, you can use "object" and "object reference" interchangeably.
其实翻译成中文,Pass an object reference to the method.和pass by reference还有多大区别呢?