m.invoke() vs. m() vs. m#()

Peter Levart peter.levart at gmail.com
Sun Dec 13 01:49:35 PST 2009

I was following the discussion about the syntax of invoking a function type (a closure) when I 

We agree that a special syntax for specifying function types (they are after all just generic 
interfaces) is fine:

#(String)Integer vs. Function1<String, Integer>

So why not adding special syntax for "invoking" a function type (a closure), for example:

#(String)Integer parseInt = #(String s) Integer.valueOf(s);

parseInt#("3") vs. parseInt.invoke("3");

This has the benefit of:
- being unambiguous (no need for special shadowing/name-space rules)
- the programmers intent is human visible (as with .invoke)
- still not so verbose as .invoke

What do you think?


P.S. I didn't check if the above syntax clashes with the intended syntax for specifying method 
references as function types.

More information about the closures-dev mailing list