Small Feedback around zip and Arrays.stream

Paul Sandoz paul.sandoz at oracle.com
Mon Apr 29 01:12:17 PDT 2013


On Apr 26, 2013, at 4:26 PM, Richard Warburton <richard.warburton at gmail.com> wrote:

> Hi,
> 
> Just had a quick review of some work code comparing imperative vs
> functional style implementations of autocorrelation.  A couple of quick
> observations:
> 
> * Static importing of Arrays.stream seems fine when its just taking an
> array as an argument, but people get significantly more confused if you're
> using its 3 overload variant.
> * The lack of unboxed overloads on Streams.zip not only has a performance
> hit, but also makes code more confusing to read, since its arguments end up
> having a .boxed() call.  This seems to confuse code reviewers.
> * Anecdotally most of my uses of zip so far have been on Collections of
> boxed primitives or arrays of primitives.
> 

And are you zipping primitive streams of the same type?

To support all forms would require zip methods for:

ref+ ref
ref + int
ref + long
ref + double
int + int
int + long
int + double
long + long
long + double
double + double

and require additional primitive specializations of BiFunction.

Paul.


More information about the lambda-dev mailing list