Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams
Stuart Marks
stuart.marks at oracle.com
Tue Mar 12 22:05:18 UTC 2019
>> Due to how Iterable is specified now it does not promise multiple iterations,
>> but due to how most (all that I know of except DirectoryStream or some 3rd
>> party) Iterables are implemented now, the common expectation is that it does.
>> By implementing more Iterable(s) that don't support multiple iteration
>> (regardless of whether they implement this new sub-type or not), this
>> expectation will be less and less honored. Perhaps this is not so bad. At
>> various occasions the specification has been changed to accommodate the
>> long-standing behavior or expectation of behavior, but this seems not to be
>> one of them.
>
> Correct. But, with separate Iterable and IterableOnce, the spec for Iterable
> can say "If you don't support multiple iteration, you should implement IO."
> Which is OK, because at least those classes are being explicit.
Right. This sort of clarification should be done as part of JDK-8186220.
s'marks
More information about the core-libs-dev
mailing list