overload patterns/anti-patterns

Brian Goetz brian.goetz at oracle.com
Sat Dec 29 06:59:49 PST 2012


> My current sense is that, no matter how much lambda-overload
> matching is tweaked, this will remain a common API design
> gotcha, and the best advice is to never overload solely
> on function type.

... where the function types have the same arity.

There's no hazard to overloading

   foo(Function)
and
   foo(BiPredicate)

Similarly, it is a key goal to make overloading on specialized return 
type safe, because we want to support constructions like:

  Stream<U> map(Function<T,U>)
and
  IntStream map(IntFunction<T>)



More information about the lambda-libs-spec-observers mailing list