Collectors update (original) (raw)
Doug Lea dl at cs.oswego.edu
Tue Jan 29 16:03:43 PST 2013
- Previous message: Collectors update
- Next message: Collectors update
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 01/29/13 17:55, Raab, Donald wrote:
Having the method name "collect" is going to make it very hard to teach folks to use the streams API with GS Collections as it means something different than our "collect" method. It may equally cause problems for folks using Groovy, Apache Commons Collections and JRuby as well.
http://groovy.codehaus.org/groovy-jdk/java/util/Collection.html#collect(groovy.lang.Closure) http://commons.apache.org/collections/api-release/org/apache/commons/collections/CollectionUtils.html We've gone through the names accumulate, tabulate (not sure if there are others)... I know there is a dwindling list of good names, and I'll settle when there are none better, but this particular name has 30+ years of prior art in Smalltalk influenced circles. It is one of the most commonly used methods in our library and these other languages/libraries. Again, I'd like to propose "aggregate" as an alternative. stream.aggregate(groupingBy(Foo::getBar))
One reason that I'm actively hostile to using "aggregate" here is that Aggregate is the only appropriate name left to use for a possible Java9 Collections overhaul.
And "accumulate" and "tabulate" are semantically strained in this role.
And like most people, I find "collect" one of the few uncontroversially easy to understand method names in the Stream API.
So, sorry; I think requiring some groovy/ruby/gs users to adapt is still the best option.
-Doug
- Previous message: Collectors update
- Next message: Collectors update
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list