forEachOrdered semantics

Tim Peierls tim at
Mon Oct 7 09:51:53 PDT 2013

If so, doesn't the name "forEachOrdered" become a bit off-target? Doc
readers are sure to confuse the ordered-ness of the stream with the
"-Ordered" modifier in the method name. Something like
"forEachSequentially" would be more on-target.


On Mon, Oct 7, 2013 at 12:38 PM, Brian Goetz <brian.goetz at> wrote:

> Recall that Stream.forEach(action) may perform the action for different
> elements in whatever order, in whatever thread, with whatever concurrency
> it chooses, and forEachOrdered(action) promises to perform the action in
> encounter order.
> Working through the specs, I think users are expecting a tail-to-head
> sequencing of actions, and that processing element n <i>happens-before</i>
> processing element n+1?
> The real question is: what should happen when you do a .forEachOrdered()
> on an unordered stream.  My first thought was that this was plain old
> forEach.  But, I think this is not what the user will expect; I believe
> they will be reasonably expecting that the action is performed in some
> order, one element at a time.
> So I'm inclined to spec that this operates in *some* order, which is the
> encounter order if one exists, and that there is a HB edge between
> successive actions?
-------------- next part --------------
An HTML attachment was scrubbed...

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