Method References

Rémi Forax forax at univ-mlv.fr
Fri Feb 26 10:00:55 PST 2010


Le 26/02/2010 17:55, Neal Gafter a écrit :
> On Fri, Feb 26, 2010 at 8:40 AM, Joshua Bloch<jjb at google.com>  wrote:
>
>    
>> I agree that method references would be a fine addition to the proposal,
>> and
>> I like the proposed syntax. I believe it's important that method references
>> work for constructors and static methods as well as instance methods.
>>
>> I am very much in favor of allowing the user to omit the type information
>> when it's unambiguous.  In fact, is their any reason to use "this" (as
>> proposed by Fredrick):
>>
>>     cb = this#saveState;
>>
>> or could we allow:
>>
>>     cb = #saveState;
>>
>> Not only is this more succinct, but it mirrors the rules for method
>> invocation, allowing "reasoning by analogy" and reducing programmer
>> astonishment.
>>
>>      
> I worry that it looks too much like a lambda or function type, but if we use
> my proposed syntax for lambda then there is no conflict.
>
> "Unambiguous" can't possibly refer to that term in the overload-resolution
> sense.
>    


Perl zealots will be jealous of the true power of Java !

class A {
   A[] A(A a) { return new A[]{a}; }

   A f() {
      return #A.((A#A(A).(A.A(#A()(null).())[0]))[0])[0];
   }
}

Rémi


More information about the lambda-dev mailing list