Re: Pointers

2011-01-29 Thread Matt Benson
Adding fuel to the fire, note that [lang] 3.0 will include the Pair class. Matt On 1/28/11, Stephen Williams wrote: > On 1/28/11 3:14 PM, James Ring wrote: >> Hey, >> >> On Fri, Jan 28, 2011 at 3:00 PM, Stephen Williams >> wrote: >>> True, you shouldn't synchronize on any object that A) you want

Re: Pointers

2011-01-28 Thread Stephen Williams
On 1/28/11 3:14 PM, James Ring wrote: Hey, On Fri, Jan 28, 2011 at 3:00 PM, Stephen Williams wrote: True, you shouldn't synchronize on any object that A) you want to change and B) can only be changed by being replaced by a newly constructed object. If Integer, for instance, had a setter metho

Re: Pointers

2011-01-28 Thread James Ring
Hey, On Fri, Jan 28, 2011 at 3:00 PM, Stephen Williams wrote: > True, you shouldn't synchronize on any object that A) you want to change and > B) can only be changed by being replaced by a newly constructed object.  If > Integer, for instance, had a setter method, then it could still have been >

Re: Pointers

2011-01-28 Thread Stephen Williams
Hah, just sent a reply stating just that. Thanks. Stephen On Fri, Jan 28, 2011 at 2:45 PM, Brent Worden wrote: > Actually, funkyChanger will not work because you are effectively > reassigning the argument. Since all arguments in Java are passed by > value, the assignment is not realized by the

Re: Pointers

2011-01-28 Thread Stephen Williams
True, you shouldn't synchronize on any object that A) you want to change and B) can only be changed by being replaced by a newly constructed object. If Integer, for instance, had a setter method, then it could still have been used in this way. However, it seems to be immutable. I generally just

Re: Pointers

2011-01-28 Thread Brent Worden
Actually, funkyChanger will not work because you are effectively reassigning the argument. Since all arguments in Java are passed by value, the assignment is not realized by the caller. The only ways to get argument changes surfaced to the caller are using a typed return or passing in an argument

Re: Pointers

2011-01-28 Thread James Ring
Hey, On Fri, Jan 28, 2011 at 2:01 PM, Stephen Williams wrote: > All objects are passed as references in Java. > All fundamental scalar types have Object wrapped versions. > An argument that is meant to be modified just needs to be an object > reference. > > So, you can simply go from: > void funk

Re: Pointers

2011-01-28 Thread Stephen Williams
All objects are passed as references in Java. All fundamental scalar types have Object wrapped versions. An argument that is meant to be modified just needs to be an object reference. So, you can simply go from: void funkyReader(int arg) { arg++; } to: void funkyChanger(Integer arg) { arg++; } If

Re: Pointers

2011-01-04 Thread Michael Giannakopoulos
Thank you all guys! You 're amazing!

Re: Pointers

2011-01-04 Thread Julien Aymé
If you only use boolean, integer and long, you can also use AtomicXXX from java.util.concurrent.atomic (if you have to use them in a multi-threaded environment). Otherwise, the MutableXXX wrappers in Commons Lang are good. Julien 2011/1/3 Paul Benedict : > Michael, > > Primitives are passed by va

Re: Pointers

2011-01-03 Thread Paul Benedict
Michael, Primitives are passed by value in Java. If you want to "modify" primitives, use the MutableXXX wrappers in Commons Lang. Paul On Mon, Jan 3, 2011 at 3:01 PM, Michael Giannakopoulos wrote: > I mean exactly the same thing as C# but from the replies i see that's a > difficult task and al

Re: Pointers

2011-01-03 Thread Michael Giannakopoulos
I mean exactly the same thing as C# but from the replies i see that's a difficult task and also that has little to do with apache commons... Because i use java a lot it's annoying the fact that specific variables that i want to change values in other functions cannot be passed as arguments but inst

Re: Pointers

2011-01-03 Thread Matt Benson
On Jan 3, 2011, at 11:54 AM, Paul Benedict wrote: > I believe you're looking for JDK 7 method handles: > http://java.sun.com/developer/technicalArticles/DynTypeLang/ > Actually it sounded to me as though he was talking along the lines of Mutable* in [lang]. :/ Matt > Paul > > On Mon, Jan 3

Re: Pointers

2011-01-03 Thread Rafał Krupiński
W dniu 03.01.2011 20:15, Stephen J. Butler pisze: 2011/1/3 Rafał Krupiński: W dniu 03.01.2011 18:45, Michael Giannakopoulos pisze: Hello to all Apache Commons Developers! I wish a happy new year and i hope that all your expectations will come true! I would like to propose a new feature in apac

Re: Pointers

2011-01-03 Thread Stephen J. Butler
2011/1/3 Stephen J. Butler : > public function foo( ref int a ) { a = 42; } > public function bar() { >  int b = 0; > >  foo( ref b ); > >  // b == 42 > } And excuse my rather bad C# code which doesn't compile... been spending way too much time in scripting languages lately. -

Re: Pointers

2011-01-03 Thread Stephen J. Butler
2011/1/3 Rafał Krupiński : > W dniu 03.01.2011 18:45, Michael Giannakopoulos pisze: >> >> Hello to all Apache Commons Developers! >> I wish a happy new year and i hope that all your expectations will come >> true! I would like to propose a new feature in apache commons... Wouldn't >> it >> be great

Re: Pointers

2011-01-03 Thread Rafał Krupiński
W dniu 03.01.2011 18:45, Michael Giannakopoulos pisze: Hello to all Apache Commons Developers! I wish a happy new year and i hope that all your expectations will come true! I would like to propose a new feature in apache commons... Wouldn't it be great if commons api provided a pointer operator (

Re: Pointers

2011-01-03 Thread Paul Benedict
I believe you're looking for JDK 7 method handles: http://java.sun.com/developer/technicalArticles/DynTypeLang/ Paul On Mon, Jan 3, 2011 at 11:45 AM, Michael Giannakopoulos < miccagi...@gmail.com> wrote: > Hello to all Apache Commons Developers! > I wish a happy new year and i hope that all your

Pointers

2011-01-03 Thread Michael Giannakopoulos
Hello to all Apache Commons Developers! I wish a happy new year and i hope that all your expectations will come true! I would like to propose a new feature in apache commons... Wouldn't it be great if commons api provided a pointer operator (like ref in C#) so as to pass arguments in functions by r