Primitive streams and optional
Brian Goetz
brian.goetz at oracle.com
Sat Nov 24 14:40:20 PST 2012
>> T[] mapped = Arrays.stream(input).map(mapper).toArray();
>
> I'm not bothered. The implementation can assume size-preservingness
> and fall back to slow secondary copy etc if it is wrong after final check
> of how many elements it saw. toArray already does this (in the
> case of unexpected growth). People may then learn that things are
> slower if they put nulls in the their collections.
The performance consequences are only part of the story. I was mainly talking of the semantics presented to the user, where the user might be confused into thinking that indexes into the source are valid in the output, but this is only accidentally true in the very common case where there are no nulls in the input. Which means users will assume it to be true more often, and be surprised.
More information about the lambda-libs-spec-observers
mailing list