Method References and partial application

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Tue Jul 5 00:41:11 PDT 2011


Hi,
comments inlined.

On Thu, Jun 30, 2011 at 7:59 PM, Reinier Zwitserloot <
reinier at zwitserloot.com> wrote:

> 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!
>
This is not ambiguous.
Consider following code in current java.

public class Test {

    static class A{
        public static void call(){
            System.out.println("A.call");
        }
    }

    static class B{
        public void call(){
            System.out.println("B.call");
        }
    }



    public static void call(Object a){

    }

    public static void main(String[] args) {
          B A=new B();
          A.call();    //B.call
    }
}


 Best Regards,
Ali Ebrahimi

>
> 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