From: Parragh Szabolcs Date: 2007-01-28T22:22:17+09:00 Subject: Re: pass by reference? --------------000802010406020906090405 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit fxn@hashref.com �rta: >> Xavier Noria wrote: >> >>> Java is pass-by-value for instance (according to the JLS) and that >>> test passes. >>> >> Could you point me to the exact locus? >> > > Sure, that's section 8.4.1 in the current edition[*]: > > "When the method or constructor is invoked (�15.12), the values of the > actual argument expressions initialize newly created parameter variables, > each of the declared Type, before execution of the body of the method or > constructor. The Identifier that appears in the DeclaratorId may be used > as a simple name in the body of the method or constructor to refer to the > formal parameter." > Thanks a lot, I was curious about this official description for a while! What I miss, however, is the explicit use of the "pass by value" expression. Bruce Eckel mentions in Thinking in Java, that both sides of the controversy have lots of propagators. Both the "everything is pass by value" theory, and the contrary one that he descrbes as: "2. Java passes primitives by value (no argument there), but objects are passed by reference. This is the world view that the reference is an alias for the object, so you don't think about passing references, but instead say "I'm passing the object." Since you don't get a local copy of the object when you pass it into a method, objects are clearly not passed by value. There appears to be some support for this view within Sun, since at one time, one of the "reserved but not implemented" keywords was byvalue (This will probably never be implemented)." What is suprising is the reference (:-)) to Sun in this context, if the JLS says otherwise. Anyways, this is not a Java list, so sorry for beeing a bit offtopic -- I just hope it helps to show, there's a great mess of notions around this topic everywhere. Bye: Szab > -- fxn > > [*] http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.1 > > > > -- Parragh Szabolcs e-mail: parragh@dayka.hu web: parszab.nir.hu --------------000802010406020906090405--