Early/late binding to data source (original) (raw)

Brian Goetz brian.goetz at oracle.com
Thu Nov 29 08:29:43 PST 2012


We've already committed to a model where stream operations do not tolerate modification of their data source during the operation. For example, this is illegal:

collection.stream().forEach(e -> collection.removeAll(e));

We've also tightened down the spec on "source sharing" and "stream reuse".

We now have to define what "during" means. We make a substantial effort to not touch the data until the user wants to do something with it. So, what should happen in this case:

List strings = new ArrayList<>(Arrays.asList("a")); Stream s = strings.stream(); strings.clear(); s.forEach(System.out::println);



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