Method calls vs lambda calls
Mark Thornton
mthornton at optrak.co.uk
Tue Dec 15 07:05:15 PST 2009
Rémi Forax wrote:
> Mark Thornton a écrit :
>> Mark Thornton wrote:
>>
>>>>
>>> A simple solution would be to specify that method valued fields are
>>> in the method namespace. Your example would then not compile. I
>>> think this would be preferable to having different syntax to
>>> discriminate between the method call and invoking a field.
>>>
>>> Mark Thornton
>>>
>>>
>>>
>> I realise that this then allows
>>
>> public class Example { private int fourtyTwo = 42;
>> public #int() fourtyTwo = #int() {return fourtyTwo;}
>>
>> public void run() {
>> System.out.println(fourtyTwo());
>> }
>> }
>>
>> I think I would accept that as the price for the more convenient
>> invocation syntax.
>>
>> Mark Thornton
>>
>>
>>
> And this will not compile :(
>
> public class Example {
> #int() fourtyTwo = #() {return 42; };
>
> {
> f(fourtyTwo);
> }
>
> public void f(#int v) {
> ...
> }
> }
>
>
>
Howard Lovatt has suggested putting method references in both namespaces
which would solve that problem.
Mark Thornton
More information about the lambda-dev
mailing list