Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams
scolebourne at joda.org
Thu Mar 14 14:50:54 UTC 2019
On Thu, 14 Mar 2019 at 14:21, Brian Goetz <brian.goetz at oracle.com> wrote:
> There's a reason it took as long as it did for Stuart to come up with
> this proposal; all the options were known for years, they all have
> problems, and the net benefit is still relatively narrow, which means we
> don't have a lot of budget before the cost-benefit becomes negative. I
> think the option proposed is the least-worst, and people still seem to
> really want to be able to foreach over streams.
The cost-benefit is definitely tight, but I think it is positive. As I
said here  there is still a case for control abstractions in Java
even when you have lambdas
A new concern from me is that this change would allow Iterable and
Stream to be used in foreach, but not Iterator. This seems like an
odd/sharp conceptual edge.
Why not make `Iterator` implement `IterableOnce`? The default method
would obviously just return `this`.
It seems to me that if we are willing to countenance foreach over a
one-shot Stream, it is inappropriate to deny foreach to a one-shot
More information about the core-libs-dev