conrad at dz015.com
Sun Feb 26 13:49:09 PST 2012
I'm getting a little confused about closures and lambdas - I originally posted this question to closures-dev, but somebody told me that that was the wrong list and the lambda-dev is the right list. To me this question crosses both concepts - anyway
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
then I can not use
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;
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
More information about the lambda-dev