RFR: JDK-8348030 : Extend Math.min and Math.max to support multiple parameters [v2]
Per Minborg
pminborg at openjdk.org
Fri Feb 7 13:19:14 UTC 2025
On Mon, 20 Jan 2025 12:51:47 GMT, Aviad Zer <duke at openjdk.org> wrote:
>> Aviad Zer has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Update Math.java by adding extended max function
>
>> Before dealing with a CSR, I suggest you socialize your idea/PR in the [core-libs-dev at openjdk.org](mailto:core-libs-dev at openjdk.org) mailing list. You could reference this PR in the initial mail.
>
> Thanks for help, I'll do that
Thanks for socializing your idea @aviad1486 !
I think we should *not* integrate this PR and there are many reasons for that including, but not limited to:
* There are easy ways to provide this kind of functionality outside the JDK.
* We are not sure there is a need for this in the community.
* Adding these overloads means we commit to supporting them in perpetuity.
* There are works ongoing to intensify `Math::min` and `Math::max`. This means we'd have to do the same here.
* There are replacements for many similar constructs (e.g. using a reduction of streams).
* The reviewing capacity is limited and currently, we are focusing on major additions to the Java platforms (e.g. Valhalla).
* It is not clear which other methods in `Math` (and `MathExact`) should be expanded in a similar way.
* It is not clear what performance, escape analysis, and inline factors this would impact.
Languages such as Haskel support "infix" operators meaning you could write something like `a 'min' b 'min' c`. If such a feature would be available in Java in the distant future, then the use of the proposed methods would be reduced but we would still have to maintain them forever.
So, I strongly suggest that we should close this PR without integrating it. Thanks again @aviad1486 for your effort.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23138#issuecomment-2642878666
More information about the core-libs-dev
mailing list