why no function types?

maurizio cimadamore maurizio.cimadamore at oracle.com
Wed Mar 7 15:13:14 PST 2012

Long story short: since function types will probably be implemented as a 
generic type in the compiler generated code (i.e. something like 
Function<A1, A2, ... An, R, E1, E2 ... Em>), function types will be 
subject to the same limitations as generic types because of 
type-erasure; the two most common issues are:

*) cannot write two overloaded methods each one accepting a different 
function type
*) cannot create an array of function types


On 07-Mar-12 9:48 PM, Antoras wrote:
> In the archive of the mailing list I found a topic which answers why
> there are no function types [1].
> But I don't really understand the reason mentioned there (something
> about erased function types after type erasure). Therefore I have to ask
> again. Can someone explain me what happens when we write something like
> return_value map((A ->  B) f);
> instead of
> return_value map(Mapper<A, B>  f);
> I thought the first one could easily translated to the second one.
> Thanks in advance
> [1]:
> http://mail.openjdk.java.net/pipermail/lambda-dev/2011-December/004326.html

More information about the lambda-dev mailing list