Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Are you sure, Mr. Gosling? Date: Wed, 8 Jun 2016 23:11:57 +0200 Lines: 30 Message-ID: References: <1eb77568-ae31-4316-ac21-a33db79c5aa4@googlegroups.com> <5c864ac4-9634-4c88-9d6b-d14dbf3b3886@googlegroups.com> <746532a2-c6db-4d58-afc0-1cc57440eff5@googlegroups.com> <9ecc34ba-fac1-45ed-88cb-71403c7c906d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net y5Q4ddJVcWJGm9ss9pJXXgIipTf8QFyhO04aeWQMMeAUlPYHI= Cancel-Lock: sha1:H1SmSLjy/fKHA5F6maQx7U6BZPc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:34578 On 08.06.2016 22:36, Eric Sosman wrote: > On 6/8/2016 2:54 PM, Robert Klemme wrote: >> [...] >> This is wrong. Objects ("reference types") are copied by reference by >> Object.clone() - regardless of whether they are mutable or not. Only >> primitive types are copied by value. > > It's always seemed to me that the clearest way to think about > this is to say *everything* is copied by value. The values may be > primitives or they may be references, but those values are copied. This is also correct and there is some merit in presenting it that way. I just believe that deviates from the usual presentation and thus might cause confusion. I think using terms like "copy by value", "copy by reference" etc. helps describe different scenarios. Of course, underneath always "something" is copied. But it is always something different. And different terms help distinguish that. Here's a nice summary of value semantics: https://courses.cs.washington.edu/courses/cse505/99au/imperative/parameters.html Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/