Specifying "abnormal" behavior
Paul Sandoz
paul.sandoz at oracle.com
Mon Nov 26 05:36:52 PST 2012
On Nov 26, 2012, at 11:10 AM, Georgiy Rakov <georgiy.rakov at oracle.com> wrote:
> Hello,
>
> now "abnormal" behavior could occur in some lambda API use cases. By
> "abnormal" I mean things like hanging, throwing OutOfMemory exception,
> etc. Such "abnormal" behavior now occurs while dealing with infinite
> streams. For instance following line of code causes hanging:
>
> *Streams.cycle(Arrays.asList(1, 2, 3)).filter(o ->
> o>4).iterator().hasNext();*
>
> So I wonder:
> 1) If spec is going to specify the circumstances which could cause such
> "abnormal" behavior, for instance "an attempt to sort infinite stream
> leads to unpredictable result".
> 2) Moreover whether spec is going to specify that behavior exactly. For
> instance instead of saying "an attempt to sort infinite stream leads to
> /unpredictable result/" it will say "an attempt to sort infinite stream
> causes /OutOfMemory exception/".
>
I think we most likely have to talk in general terms with some non-normative examples. Those general terms should refer to the use of the limit operation and possibly that related to I/O sources.
For example, if a "uniqueElements" occurs before "sorted" there might be cases, depending on the input, where evaluation does not terminate and other cases where evaluation may result in an OOM either from "uniqueElements" or "sorted".
Paul.
More information about the lambda-dev
mailing list