On Thu, Dec 12, 2024 at 6:22 PM Ethan McCue <et...@mccue.dev> wrote:

> Placement in the standard library aside, I think Java needs value types
> and patterns before a non-throwing version of Math.multiplyExact can be
> made that achieves the same semantic goals.
>
> switch (Maths.multiplyExact(a, b)) {
>     case Product.of(long result) -> {}
>     case Product.overflow() -> {}
> }
>

Well, for that matter, if methods that receive lambdas could inline along
with the lambda, the error path could just be a passed in lambda. But since
we're not there yet I'm looking for short-term options to use the *Exact
functions without causing massive overhead when they overflow.

Reply via email to