Stream of infinite number of elements

Paul Sandoz paul.sandoz at oracle.com
Fri Dec 28 08:14:12 PST 2012


On Dec 26, 2012, at 3:23 PM, Denis DEBARBIEUX <denis.debarbieux at inria.fr> wrote:

> Hi all,
> 
> To implement the interface /Stream/, I have to implement methods like 
> /max, min, sorted/.
> 
> What is expected by the interface when my stream is infinite?

Undetermined behaviour, unless those terminal operations are prefixed with an intermediate limit operation.

The first two might never return and the latter one will most likely throw an OOE.


> Throw an 
> exception (does the interface provide an InfiniteStreamException?) or 
> implement them as an any time algorithm?
> 

We are considering a cancel or while operation that on say a met temporal condition will ensure no more elements are available, thus non-short-circuit terminal operations should terminate under such conditions.

Originally we tried to detect cases when an infinite stream was hooked up to something that would be known to not terminate but we cannot capture all such cases so rather than partially supporting this we decided to go for the "developer beware" option.

Paul.


More information about the lambda-dev mailing list