[vector] Vector API -- alignment with value types

Brian Goetz brian.goetz at oracle.com
Thu Feb 21 15:09:31 UTC 2019



>
> Looking at the changes in tests/benchmarks, the new API form looks 
> more verbose:
>
>
> -        var acc = L128.zero(); // IntVector
> +        var acc = LongVector.zero(L128); // IntVector
>
> -            var bacc = B128.zero();
> +            var bacc = ByteVector.zero(B128);
>
> -                var v1 = L128.fromArray(data, i + j);
> +                var v1 = LongVector.fromArray(L128, data, i + j);
>
> The latter doesn't benefit from type information available for Species 
> and requires XxxVector to avoid redundant casts.

This is true if you want to be specific about your species. However, I 
think many users will be happy to never thing about species ever, and 
simply use the biggest vector available, in which case the code looks like:

> -        var acc = L128.zero(); // IntVector
> +        var acc = LongVector.zero(); // IntVector
>
> -            var bacc = B128.zero();
> +            var bacc = ByteVector.zero();
>
> -                var v1 = L128.fromArray(data, i + j);
> +                var v1 = LongVector.fromArray(data, i + j); 

It's true that "LongVector" has more characters than "L128", but what I 
like about this code is that it is free of accidental low-level detail, 
and instead focuses on a higher-level abstraction, "vector of long".


More information about the panama-dev mailing list