Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

Mike Duigou openjdk at
Tue Mar 5 20:43:51 UTC 2019

I don't believe that I would use the proposed enhancement to the for 
statement. For me there is cognitive load reduction in using a 
symmetrical method for all iterations even if they end up being a little 
more complicated for individual cases. Usually, for me, I use streams. 
Even the more complicated patterns such as the presented example will 
hopefully be familiar because they are repeated in many places 
throughout the code. Truly unusual or unique usages are hopefully very 

To choose between old style for, enhanced for, or streams based on which 
warts are to be avoided is just frustrating. Mixing idioms or required 
mixing of idioms produces the least satisfying result. Was the use of a 
particular idiom a necessity? A choice? Of no consequence? This gets 
harder to decode with a larger number of available idioms.

I've seen library functions (usually statically imported) used for the 
"(Iterble<T>) stream::iterator" construction that presented it as 
"iterable(stream)". Not something I would use but it seemed clean enough 
for those who wanted it.



More information about the core-libs-dev mailing list