Location of getStreamState [it2-bootstrap]

Brian Goetz brian.goetz at oracle.com
Mon Jul 30 21:47:03 PDT 2012


One of the central themes of Iteration 2 is that streams are NOT Iterables.  They are more like Iterators.  

It has nothing to do with 'discouraging external iteration'.  It has to do with presenting the right user model.  (Think about streams backed by IO or a hardware random number generator.  They're more like Iterator than Iterable.) 

What you want to do is:

  names.filter(…)
              .forEach(…);



On Jul 30, 2012, at 8:59 PM, Deepak S Patwardhan wrote:

> Hello,
> 
> The following code works in the current lambda implementation (filter
> returns Iterable)
> 
> Collection<String> names = ...
> for (String name : names.filter(s -> s.length() > 10)) {...}
> 
> However, it will not work with it2-bootstrap because filter will return
> Stream, which is not an Iterable.
> 
> Is this just a side-effect of the way Stream API has been (currently)
> written OR is it a design goal to discourage external iteration on Stream?
> 
> Regards,
> Deepak S Patwardhan.
> 
> -----Original Message-----
> From: Brian Goetz [mailto:brian.goetz at oracle.com] 
> Sent: 30 July 2012 18:29
> To: Deepak S Patwardhan
> Cc: lambda-dev at openjdk.java.net
> Subject: Re: Location of getStreamState [it2-bootstrap]
> 
>> I am trying to understand the relation between Streamable and Stream 
>> interfaces. I see that Streamable has a method named getStreamState - 
>> should this not be in Stream ?
> 
> The role of getStreamState is still under discussion.  It may be exposed, or
> removed.  Right now it exists only for the implementation, not the API.
> 
>> On a lighter note, I was wondering if the *main* interface inside 
>> java.util.streams is Stream or is it StreamOps?
> 
> Note that StreamOps is not a public class.  
> 
> 
> 



More information about the lambda-dev mailing list