Method calls vs lambda calls

Stefan Schulz schulz at the-loom.de
Tue Dec 15 06:44:02 PST 2009


Am 15.12.2009 15:07, schrieb Mark Thornton:
> Alex Blewitt wrote:
>> This was, of course, a leading question. Now consider:
>>
>>>>>>> public class Example { #int()       public fortyTwo = #int()
>>>>>>> { return 42; }
>>>>>>>    public int fortyTwo() {
>>>>>>>      return 6*9;
>>>>>>>    }
>>>>>>>    public void run() {
>>>>>>>      System.out.println(fortyTwo())
>>>>>>>    }
>>>>>>> }
>>>>>>>
>>
>>
>> Sent from my (new) iPhone
>>
>>
> 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

Yep, this is what I was thinking of on my first reply wrt. compile time 
error. Same scope for method and function.
Might be easier to catch if function variables were defined resembling a 
method definition:

   public int #fortyTwo() = #() { return 42; }; // or #() (42);
   public int fortyTwo() { return 6 * 9; }

Stefan


More information about the lambda-dev mailing list