Collectors update
Brian Goetz
brian.goetz at oracle.com
Thu Jan 31 14:37:08 PST 2013
> Just throwing this out there: Have we already strongly considered the
> heretical idea of just naming it reduce()?
Yes. There are a few reasons we leaned towards a different name here.
1. (Pedagogical): The *mutable* reduce-like/fold-like methods have a
different feel than the more functional analogues.
2. (Practical): Overloading methods that take the same-shape lambdas
causes use-site ambiguity problems. Since there are reduce forms that
look suspiciously like collect forms, this was an issue.
> It's distinguished from the others by the type it takes (and that's not
> a lambda-able type so no worries on that front).
No, because there's the multi-arg collect() form. Which is not only
useful (collect(ArrayList::new, ArrayList::add, ArrayList::addAll)) but
also usefully pedagogically (in that the single-arg collect then becomes
clearly a generalization of the three-arg one.)
> If we were uncomfortable calling the type accepted Reducer, perhaps
> there's... MutatingReducer. Bleh.
We had that once! MutableReduce, it was. Though mutableReduceUnordered
is a mouthful.
More information about the lambda-libs-spec-experts
mailing list