No-reuse-streams (original) (raw)
Paul Sandoz paul.sandoz at oracle.com
Mon Nov 26 09:54:54 PST 2012
- Previous message: No-reuse-streams
- Next message: No-reuse and stream destructuring as (first, rest) pair
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Nov 26, 2012, at 6:39 PM, Remi Forax <forax at univ-mlv.fr> wrote:
On 11/26/2012 06:22 PM, Paul Sandoz wrote:
On Nov 26, 2012, at 5:45 PM, Henry Jen <henry.jen at oracle.com> wrote:
On Nov 26, 2012, at 8:21 AM, "David M. Lloyd" <david.lloyd at redhat.com> wrote:
Should the following throw an ISE on the last line of the following?
Stream s = .. Object i1 = s.findFirst(); Stream s1 = s.map(...); i.e. should we fail on the s.map(...) or just when a terminal operation occurs, if at all? I agree with you and Rémi - this should fail.
While it may be "consistent", what is the obvious alternative when need to do something like this? A use case like this is probably following, For a input stream, find a marker, and then continue to process the rest of stream. That seems like a use-case for dropWhile or skipWhile. take the stream, create an iterator, iterate until you have your marker, wrap the iterator as a new stream (this trick is from Brian). You lost some information about the size of the stream etc, but usually you don't care because on a IO stream these informations are not known.
Yes, use iterator as the "escape hatch".
Paul.
- Previous message: No-reuse-streams
- Next message: No-reuse and stream destructuring as (first, rest) pair
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list