Stream, spliterator, supplier and size (original) (raw)

Remi Forax forax at univ-mlv.fr
Fri Dec 14 06:49:47 PST 2012


On 12/14/2012 03:39 PM, Remi Forax wrote:

Brian explains why there is methods in Streams that takes a Supplier and the flags in a previous mail (I'm too lazy to find it now). Stream stream(Supplier<Spliterator> supplier, int flags)

I've trouble to understand why we need to expose two semantics to our poor users, I think it's better to decide whenever (1) the spliterator is created when collection.stream() is called or (2) the spliterator is created when a terminal operation like stream.forEach is called. It has severe implications on the way the pipeline works under the hood because the pipeline ops may relies on the size of the collection which may be different if the collection is mutated between the creation of the stream and the call to the terminal operation. cheers, Rémi

After thinking a little bit more, I will vote for (1). We have decided that a Stream was more an Iterator than an Iterable, that's why we have decided to 'close' the stream after use i.e. to not reuse a Stream.

Rémi



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