Nominal typing or structural typing?
Brian Goetz
brian.goetz at oracle.com
Sat Dec 17 11:17:33 PST 2011
> I'm worried about lambdas effect on the generation of classfiles
>
> First, that they aren't held in a separate class file, because that is one
> of the reasons anonymous classes are frowned for more performance sensitive
> areas.
Lambda expressions create no side-file artifacts.
> Second, that they reuse definitions with the same number and type of
> arguments - structural typing - i don't really just want to replace
> anonymous class runtime explosion with the lambda equivalent, but have
> something better.
No, we are not introducing structural function types to Java at this
time. This idea has been rejected after extensive exploration, largely
because *erased* function types would be terrible.
What we do re-use is applicable interfaces of the "right shape", of
which many already exist (Runnable, Comparator, etc.) This is what Java
developers have done since day 1 -- model functions as interfaces with
one method, and we piggyback on that approach. We introduce no new
kinds of types to the type system; instead, lambda expression become a
way to create instances of types like Runnable and Comparator.
More information about the lambda-dev
mailing list