heads-up: biggie overload rewrite
Richard Warburton
richard.warburton at gmail.com
Thu Jul 25 15:13:27 PDT 2013
Hi,
>From a language perspective, the problem is simple: we can't type check
> 's.length()' until we know that 's' is a String, and we can't figure that
> out until we look at the assignment target, and we can't do that until
> overload resolution is done. In other words, there is not a
> context-independent way to figure out that
> 'Comparator.comparing(s->s.length())' is best treated as an invocation of
> 'comparing(ToIntFunction)'.
>
Correct me if I'm wrong, but at least this means that developers should be
able to provide sufficient information for the compiler to correctly infer
the lambda expression's type by writing:
Comparator.comparing((String s) -> s.length())
rather than
Comparator.comparing((ToIntFunction<String>)(s -> s.length()))
I suspect that providing argument types is a lot less of a leap for a
developer to make when fixing a compile error than providing a full
functional interface type.
regards,
Dr. Richard Warburton
http://insightfullogic.com
@RichardWarburto <http://twitter.com/richardwarburto>
More information about the lambda-dev
mailing list