Collectors update
Kevin Bourrillion
kevinb at google.com
Thu Jan 31 15:02:14 PST 2013
I'm going to have to frequently apologize for the circular nature of many
of my comments. I wish that I'd always had time to follow the discussions
from the start.
On Thu, Jan 31, 2013 at 2:37 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 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.
>
Do they truly, from the consuming perspective? I'm not sure.
> 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.)
I strongly question the idea that that three-arg collect() method is
helping anyone pedagogically. I've come across it many times and even I
don't have the patience to sit down and try to puzzle out what it does and
why I need it. (That's my reaction to probably 50% of the API, btw.) Why
is it a collect() method instead of just another way to get a Collector?
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.
>
And again, I'm not sure that the extra word is needed from the consumer's
perspective; more for the implementor (of the thing now called Collector).
--
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb at google.com
More information about the lambda-libs-spec-observers
mailing list