From conrad at dz015.com Sun Feb 26 12:18:13 2012 From: conrad at dz015.com (Conrad Winchester) Date: Sun, 26 Feb 2012 20:18:13 +0000 Subject: Function Pointers Message-ID: <0AEA9648-C3E2-428D-8E9B-CA1EDC615483@dz015.com> Hi all, my name is Conrad Winchester and I am a long time developer. I am currently experimenting with the new lambdas and function pointers in the Java 8 developer preview. I have come across something that strikes me as a little inconsistent in the current way that they are handled and just wanted to see what other people think. I will try to be succinct: I wish to add and remove function pointers to collections. I refer to the functions using a this reference. Essentially the issue is this. If I use collection.add(this#methodName) then I can not use collection.remove(this#methodName) because the reference 'this#methodName' is different to the first one. I think this is due to the way that SAM interfaces are used to wrap the closures. A side effect of this is that this will return false public boolean checkConsistency() { SomeSAMInterface m1 = this#methodName; SomeSAMInterface m2 = this#methodName; return m1==m2; } I personally think that every time I use 'this#methodName' it should return the same reference. Is this correct? Are there any plans to make method pointers always point to the same thing. If not it makes it much more awkward to use them Thanks Conrad Winchester From forax at univ-mlv.fr Sun Feb 26 13:15:25 2012 From: forax at univ-mlv.fr (=?ISO-8859-1?Q?R=E9mi_Forax?=) Date: Sun, 26 Feb 2012 22:15:25 +0100 Subject: Function Pointers In-Reply-To: <0AEA9648-C3E2-428D-8E9B-CA1EDC615483@dz015.com> References: <0AEA9648-C3E2-428D-8E9B-CA1EDC615483@dz015.com> Message-ID: <4F4AA0ED.4060404@univ-mlv.fr> On 02/26/2012 09:18 PM, Conrad Winchester wrote: > Hi all, > > my name is Conrad Winchester and I am a long time developer. I am currently experimenting with the new lambdas and function pointers in the Java 8 developer preview. I have come across something that strikes me as a little inconsistent in the current way that they are handled and just wanted to see what other people think. I will try to be succinct: > > I wish to add and remove function pointers to collections. I refer to the functions using a this reference. Essentially the issue is this. If I use > > collection.add(this#methodName) > > then I can not use > > collection.remove(this#methodName) > > because the reference 'this#methodName' is different to the first one. I think this is due to the way that SAM interfaces are used to wrap the closures. > > A side effect of this is that this will return false > > public boolean checkConsistency() > { > SomeSAMInterface m1 = this#methodName; > SomeSAMInterface m2 = this#methodName; > return m1==m2; > } > > I personally think that every time I use 'this#methodName' it should return the same reference. Is this correct? > > Are there any plans to make method pointers always point to the same thing. If not it makes it much more awkward to use them > > > Thanks > > Conrad Winchester Hi Conrad, wrong mailing list, the one you are looking for is: lambda-dev at openjdk.java.net see you soon. R?mi