Method References and partial application

Reinier Zwitserloot reinier at zwitserloot.com
Thu Jun 30 09:29:15 PDT 2011


This syntax can't work; the 'int' there would be fine, but if its an object
type there's no way to tell the difference (as it might as well be a
variable reference - in general if at some point the parser can parse either
a type or an expression and it'd both be legal java code you have a
problem).

i.e:

Object Object = null; // stupid name, but legal.
Test#concatToStringCalls(new Object(), Object); // ambiguous!

Count me in with the: 'Just use a lambda for this' crowd. We'd have to come
up with an entirely new symbol, or declare a magic name, to signify its
partial application. Something like:

Test#concatToStringCalls(new Object(), _); // _ is a legal identifier name,
but here we consider it 'magic'.



 --Reinier Zwitserloot



On Sat, Jun 25, 2011 at 1:38 PM, Ali Ebrahimi <ali.ebrahimi1781 at gmail.com>wrote:

> Hi Brian,
> Is partial application Support for Method References in current scope?
>
> class Test{
>    public static int multiply(int x, int y){    return x * y;}
>
>    public static void main(String... args){
>            SAM2 sam2 = Test#multiply;
>            SAM1 sam1 = Test#multiply(10,int);
>            SAM0 sam0 = Test#multiply(10,20);
>            SAM0 sam00 = sam1#apply(20);
>    }
> }
>
> Best Regards,
> Ali Ebrahimi
>
>


More information about the lambda-dev mailing list