Re: pass by reference
- From: "Arved Sandstrom" <asandstrom@xxxxxxxxxxxxx>
- Date: Sat, 05 Apr 2008 23:35:57 GMT
"Roedy Green" <see_website@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:fhqfv3tl9v507ngchf95shmuv3i11c7gik@xxxxxxxxxx
On Sat, 05 Apr 2008 12:01:49 GMT, "Arved Sandstrom"
<asandstrom@xxxxxxxxxxxxx> wrote, quoted or indirectly quoted someone
who said :
I may get flunked on a certification exam, but I call that
passing the object by reference.
Language is for communication. If you use a word to mean something
different from everyone else does, you just create chaos when you
speak.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
However, I don't think I mean "pass by reference" and "pass by value" as
anything other than the intuitive meanings:
a) pass by value - the method sees a copy of the parameter, whatever that
may be;
b) pass by reference - the method sees an alias to the parameter. If the
method uses the parameter it is using the actual thing referred to.
With objects Java does (b). I don't care if you call it "passing the
reference by value", or "passing a pointer", or whatever. If I do
Some Object so = new SomeObject(...);
makeChangesToFields(so);
then the fields in 'so' are changed outside the method. This is
pass-by-reference behaviour, not pass-by-value behaviour.
For the record I don't like the "swap" example that gets trotted out to
explain that Java is not pass-by-reference (as an example,
http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html).
It's disingenuous. If I write the same example using C++ with pointers to
objects, I get the same results...surprise, surprise.
AHS
.
- Follow-Ups:
- Re: pass by reference
- From: Roedy Green
- Re: pass by reference
- From: Peter Duniho
- Re: pass by reference
- References:
- pass by reference
- From: angelochen960@xxxxxxxxx
- Re: pass by reference
- From: Chase Preuninger
- Re: pass by reference
- From: Andreas Leitgeb
- Re: pass by reference
- From: Lew
- Re: pass by reference
- From: Arved Sandstrom
- Re: pass by reference
- From: Roedy Green
- pass by reference
- Prev by Date: Re: pass by reference
- Next by Date: Re: pass by reference
- Previous by thread: Re: pass by reference
- Next by thread: Re: pass by reference
- Index(es):
Relevant Pages
|
|