Review Request: 8004201: add reducers to primitive type wrappers

David Holmes david.holmes at oracle.com
Thu Dec 6 04:42:59 PST 2012


On 6/12/2012 7:27 AM, Akhil Arora wrote:
> Updated - http://cr.openjdk.java.net/~akhil/8004201.1/webrev/
>
> - delegate to Math.min/max for int/long/float/double
> - rename Boolean.and/or/xor to logicalAnd/logicalOr/logicalXor
> - removed Character variants of min/max/sum
>
> On 12/02/2012 05:50 PM, David Holmes wrote:
>> Is it really necessary/desirable to flag all of these as " Suitable for
>> conversion as a method reference to functional interfaces such as ..." ?
>
> Not necessary, but it does provide a hint as to their intended use to a
> casual browser of these docs.

I don't find it desirable either.

>> This style:
>>
>> + * @param a a boolean argument.
>> + * @param b another boolean argument.
>>
>> is at odds with the style used elsewhere for new Functional APIs, and
>> with the style of other methods in these classes. Can we just use "first
>> operand" and "second operand" for all of these?
>
> It is consistent with Math.min/max, which use the a/b style. Since these
> methods are not in one of the functional package, is'nt it better to
> stick to the local style?

Why do you consider Math to be representative of "local style"? Math 
isn't even internally consistent with its style - see Math.max versus 
Math.addExact etc. And Math doesn't include the arguments type in its 
description. (Consistency is not a strong point in the Java APIs :( )

Given these are being added to support the new functional type I suggest 
using the same style as for the functional types.

>> Character.sum does not make sense to me. Who adds together characters?
>> I'm not even sure min and max are worth supporting for Character.
>
> Good point - removed these methods for Character.
>
>> I disagree with other suggestions to use the Math functions for
>> float/double. I think all these methods should use the underlying
>> primitive operator regardless of type.
>
> Are you disagreeing only for float/double or for int/long also? Can you
> provide more information as to why you disagree?

I withdraw my objection.

David
-----

> Thanks
>
>> Thanks,
>> David
>> -----
>>
>> On 1/12/2012 4:44 AM, Akhil Arora wrote:
>>> Hi
>>>
>>> Requesting review for some basic functionality related to lambdas -
>>>
>>> Add min, max, sum methods to the primitive wrapper classes - Byte,
>>> Short, Integer, Long, Float, Double and Character so as to be able to
>>> use them as reducers in lambda expressions. Add and, or, xor methods to
>>> Boolean.
>>>
>>> http://cr.openjdk.java.net/~akhil/8004201.0/webrev/
>>> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8004201
>>>
>>> Thanks
>


More information about the lambda-dev mailing list