4 ms·
Thank you sir for pointing this out. I recently ran into a similar argument with an Oracle trainer whether Java has pass-by-reference semantics. The entire Java
by wyuenho 10y ago
Thank you sir for pointing this out. I recently ran into a similar argument with an Oracle trainer whether Java has pass-by-reference semantics. The entire Java community seems adamant that Java has no pass-by-reference, but only pass-by-value. This blog post reminds me of that argument.
In Java, Python, Javascript and many other languages, objects pointers are passed by value, but the contents of which are shared between the caller and the callee, so the modification of which is visible from both sides. If we take the definition of pass-by-reference or call-by-reference semantics to mean that, then these languages are pass by reference by default. Apparently, that's not the definition, which in my opinion is rather strange that we are still stuck in a definition that predates OOP, when people mostly concerned with simple primitive values as opposed to composites.
It appears that Barbara Liskov has recognised this and coined call-by-sharing in 1974. 43 years later, practitioners are still arguing in the C++ frame of mind and failed to disseminate the more modern and suitable term of call-by-sharing. This is rather disappointing to me.