3 ms·
> This article is overly pedantic. Java's semantics are pass-by-value only of you consider that the "values" that are being passed are pointers. Which is exact
by masklinn 9y ago
> This article is overly pedantic. Java's semantics are pass-by-value only of you consider that the "values" that are being passed are pointers.
Which is exactly what they are.
> But Java doesn't have first-class pointers, it has implicit pointers. The only thing you can do with a Java pointer "value" is to tacitly dereference it.
So? Just because you're not given direct access to the value itself doesn't change the semantics of the language. If you assume "pass-by" is strictly dichotomous and the choices are either value or reference, then Java can only be pass-by-value, its semantics simply don't allow the possibility of it being pass-by-ref.
IIRC the Python community calls it "pass reference by value", sadly they seem to be more or less the only ones doing so. CLU called it "pass by sharing".
> All Java "values" are (tacit) pointers to objects [1]. Pounding your fist on the table and insisting that Java is pass-by-value because you can't write a swap(x,y) function obscures this crucial difference.
Then again that Java's boxed types are boxed seems pretty obvious...
- lisper 9y ago> If you assume "pass-by" is strictly dichotomous and the choices are either value or reference Well, there's your problem right there: pass-by is not "strictly dichotomous." There are (at least) three different argument-passing disciplines in common use. If you insist on using only two words to distinguish among them you will cause unnecessary confusion.
- masklinn 9y ago> Well, there's your problem right there It's not my problem, it's yours. > pass-by is not "strictly dichotomous." Which you may have wanted to explain in your essay if you believe it instead of going on worthless rants. > If you insist on using only two words to distinguish among them you will cause unnecessary confusion. I don't.