<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>va_coder</author><text>The user refractedthought at reddit had the best explanation IMO:&lt;p&gt;Ok, I think the real losers in this discussion are the ones who fail to see both sides of the issue. We can cherry pick &quot;refrence&quot; definitions if we want, but really the nuts and bolts come down to this: Passing by value means that a copy of the parameter is made when the function is called and any changes to that variable will not be reflected outside of the function. Passing by reference means you pass a pointer to your data (and nothing more) so the function can dereference the parameter and affect data that exists outside of the function.&lt;p&gt;All non-primitives in Java are implicit pointers, so when you pass one of these into a function, you are passing a pointer (or reference) to data that exists outside of the function. However, the reference itself, as it exists inside the function, can be changed to point toward something else. Essentially, the implicit pointer is passed by value, and that value can be altered without affecting anything outside the function.&lt;p&gt;So technically yes, you could get away with calling this pass-by-value. However, the spirit of pass-by-reference is maintained for any part of the data that most people care about. The syntax is different from a pass-by-reference in C++, and there&apos;s a silly little trick you can do by changing the reference pointer (or silly trick you can&apos;t do by changing the pointer outside the function) but for all practical purposes you are doing the same thing.&lt;p&gt;In my opinion, if you want to insist that Java strictly follows pass-by-value, then I think it has ceased to be a relevant distinction.</text><parent_chain></parent_chain></comment><story><title>Java is pass-by-value, Dammit (and so are Ruby and Python, Dammit)</title><url>http://javadude.com/articles/passbyvalue.htm?repost</url><text></text></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>jganetsk</author><text>&lt;i&gt;Can you write a traditional swap(a,b) method/function in the language?&lt;/i&gt;&lt;p&gt;What about languages that are immutable by default, like Haskell, OCaml, and Erlang? You can&apos;t write a swap function. Therefore, are they pass-by-value?&lt;p&gt;Actually, in OCaml, you can write the swap function.&lt;p&gt;&lt;pre&gt;&lt;code&gt;   let swap a b =
     let temp = !a in
     a := !b;
     b := temp

   let x = ref 3 in
   let y = ref 8 in
   swap x y
&lt;/code&gt;&lt;/pre&gt;
But now, you are passing references by value, as Java does. So maybe they are pass-by-value. But, when your language is immutable, pass-by-reference (whatever that would mean), doesn&apos;t effect the language semantics. They are pass-by-(it&apos;s-moot).</text><parent_chain></parent_chain></comment><story><title>Java is pass-by-value, Dammit (and so are Ruby and Python, Dammit)</title><url>http://javadude.com/articles/passbyvalue.htm?repost</url><text></text></story>