Design for collections upgrades
Neal Gafter
neal at gafter.com
Sun Mar 13 09:37:06 PDT 2011
I suggest that in-place operations, if included, should be named something like
void Collection.retainAll(Predicate<E> predicate);
void Collection.removeAll(Predicate<E> predicate);
I think this naming would remove confusion vs the other aggregate operations.
As for the bulk data operations that do not modify the input
collection, making them lazy and providing toArray, toList, toSet etc
eager operations solves many issues, including what kind of collection
to build and how to reduce user confusion arising from the existence
of related but semantically distinct eager/lazy APIs. I don't think
we need toStream or it's ilk, as collection and Iterable are already
stream
types. I do believe we need toParallel to enter a realm where the
operations, while still lazy, will be done using concurrency on the
final reduce/toArray/toList/etc.
Finally, I should point out to the language designers out there that
these APIs can be structured as a monad, not because we want
programmers to think of them as such but because it provides great
flexibility in clients wanting to port or reuse code from one
computational domain to another. Some expert familiar with such
techniques should take a more firm role influencing the shape of these
APIs. I don't know who is on the expert group so I can't recommend
anyone in particular.
Cheers,
Neal
More information about the lambda-dev
mailing list