Specifying "abnormal" behavior
Brian Goetz
brian.goetz at oracle.com
Mon Nov 26 07:42:49 PST 2012
I don't think we want to try and spec that, any more than we want to
specify when the for-loop can result in an infinite loop. I think
something like "the programmer is responsible for ensuring the loop can
terminate" is more appropriate; trying to do much better generally sets
you on a slippery slope towards the halting problem.
We will absolutely definitely not try to specify exact behavor as you
ask in (2); this gives us implementation constraints and a bug tail for
no benefit.
On 11/26/2012 5:10 AM, Georgiy Rakov 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/".
>
> Thanks, Georgiy.
>
More information about the lambda-dev
mailing list