Design for collections upgrades

Rémi Forax forax at
Sun Mar 13 16:01:47 PDT 2011

On 03/13/2011 09:15 PM, Sam Pullara wrote:
> If we name List.filter() and Iterable.filter() the same thing there will be no way to get to the default lazy version of filter() on a List even if the Iterable version of filter() is lazy without either naming the methods differently or requiring something that changes a List into something that doesn't implement List but does implement Iterable or another streaming interface. Am I missing something?

if Iterable.filter() is lazy, List.filter() must be lazy.
overridden method should never change the semantics.

> One solution might be to put those methods on Iterator and require .iterator() (simply another name for .asStream() really). This would be kind of nice in that the for() loop would now use the lazy versions by default.

iterator() is not equivalent to asStream() if we want to be able to iterate
several time on the same filtered collection.

> Higher-level question: Does anyone really think that developers should use the eager versions or are we putting them in there as some kind of idiot proof implementation?

Eager in-place versions are useful.
I don't know for the other versions.

> Sam


More information about the lambda-dev mailing list