Bikeshed opportunity: filter/map/reduce naming (original) (raw)

Brian Goetz brian.goetz at oracle.com
Sat Dec 1 11:10:53 PST 2012


But, people have complained about filter because they can't tell whether we are filtering OUT the elements matching the predicate, or including them. Some of these people have suggested "where(Predicate)" as an alternative. Which seems OK to me. "select" is the most classic name. Especially for a database company :-) Also "selectAny" etc.

Given the database imperative you cite (there's also LinQ), if we were to use select() at all, it would be for what is now called map?

xs.where(x -> x.getFoo() > 3) .select(x -> x.getBar()) ...

If/when we get tuples that might actually look nice:

xs.where(x -> x.getFoo() > 3) .select(x -> #( x.getBar(), x.getBaz() )) // stream of (bar,baz) ...

But probably should stay away from select entirely for these reasons.

Still a slight preference for "where" over "filter":

list.where(e -> e.hasChildren()) .map(e -> e.getFirstChild()) .minBy(Child::getAge)

Other ideas?



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