Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-25 Thread Raffaello Giulietti
Brian Goetz Date: Wednesday, 25 May 2022 at 17:18 To: Raffaello Giulietti , core-libs-dev@openjdk.java.net Subject: Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts Another way to evaluate answers here is: are we inventing new relations, or merely clarifying old ones

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-25 Thread Brian Goetz
s-dev@openjdk.java.net *Subject: *Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts This work is quite timely as we are now paving the way for primitive type patterns over in Project Amber, and also has a nontrivial connection with Valhalla.  If you'll pard

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-25 Thread Brian Goetz
Themotivation behind this PR isnot driven by pattern matching:John Rose (the reporter of the JBS issue) is concerned about having safer casts that, in addition, can be JITted to efficient code. Yes, of course.  But also, as the platform evolves, it often happens that the same issues arise

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-25 Thread Raffaello Giulietti
-libs-dev@openjdk.java.net Subject: Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts This work is quite timely as we are now paving the way for primitive type patterns over in Project Amber, and also has a nontrivial connection with Valhalla. If you'll pardon a

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v6]

2022-05-25 Thread Raffaello Giulietti
> Add a family of "safe" cast methods. Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision: 8279986: methods Math::asXExact for safely checked primitive casts - Changes: - all: https://git.openjdk.java.net/jdk/pull/8

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-23 Thread Brian Goetz
This work is quite timely as we are now paving the way for primitive type patterns over in Project Amber, and also has a nontrivial connection with Valhalla.  If you'll pardon a brief digression... Instanceof and casting work together in a familiar way: before you cast, you first ask instanceo

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v5]

2022-05-23 Thread Raffaello Giulietti
> Add a family of "safe" cast methods. Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision: 8279986: methods Math::asXExact for safely checked primitive casts - Changes: - all: https://git.openjdk.java.net/jdk/pull/8

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v4]

2022-05-23 Thread kristylee88
On Mon, 23 May 2022 18:37:26 GMT, Raffaello Giulietti wrote: >> Add a family of "safe" cast methods. > > Raffaello Giulietti has updated the pull request incrementally with one > additional commit since the last revision: > > 8279986: methods Math::asXExact for safely checked primitive casts

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v4]

2022-05-23 Thread Raffaello Giulietti
> Add a family of "safe" cast methods. Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision: 8279986: methods Math::asXExact for safely checked primitive casts - Changes: - all: https://git.openjdk.java.net/jdk/pull/8

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v3]

2022-05-23 Thread Joe Darcy
On Tue, 10 May 2022 13:47:35 GMT, Raffaello Giulietti wrote: >> Add a family of "safe" cast methods. > > Raffaello Giulietti has updated the pull request incrementally with one > additional commit since the last revision: > > 8279986: methods Math::asXExact for safely checked primitive casts

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v3]

2022-05-10 Thread Raffaello Giulietti
> Add a family of "safe" cast methods. Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision: 8279986: methods Math::asXExact for safely checked primitive casts - Changes: - all: https://git.openjdk.java.net/jdk/pull/8

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v2]

2022-05-10 Thread Raffaello Giulietti
On Tue, 10 May 2022 04:42:19 GMT, Joe Darcy wrote: >> Raffaello Giulietti has updated the pull request with a new target base due >> to a merge or a rebase. The incremental webrev excludes the unrelated >> changes brought in by the merge/rebase. The pull request contains four >> additional com

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v2]

2022-05-09 Thread Joe Darcy
On Mon, 9 May 2022 09:26:58 GMT, Raffaello Giulietti wrote: >> Add a family of "safe" cast methods. > > Raffaello Giulietti has updated the pull request with a new target base due > to a merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase.

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v2]

2022-05-09 Thread Raffaello Giulietti
On Mon, 9 May 2022 09:26:58 GMT, Raffaello Giulietti wrote: >> Add a family of "safe" cast methods. > > Raffaello Giulietti has updated the pull request with a new target base due > to a merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase.

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts [v2]

2022-05-09 Thread Raffaello Giulietti
> Add a family of "safe" cast methods. Raffaello Giulietti has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revis

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-05 Thread Raffaello Giulietti
On Thu, 5 May 2022 15:07:32 GMT, Michael Hixson wrote: > Rationale: It loses information. It truncates the sign, so the value can't be > round-tripped. I think it would be the only lossy transformation permitted by > the to*Exact methods? Right. - PR: https://git.openjdk.java.net

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-05 Thread Michael Hixson
On Thu, 5 May 2022 14:32:36 GMT, Raffaello Giulietti wrote: > So, what is the use case or the rationale for throwing on -0.0? Rationale: It loses information. It truncates the sign, so the value can't be round-tripped. I think it would be the only lossy transformation permitted by the `to*E

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-05 Thread Raffaello Giulietti
On Thu, 5 May 2022 10:11:05 GMT, Raffaello Giulietti wrote: > Add a family of "safe" cast methods. The JLS specifies that the cast (officially, "narrowing primitive conversion") (long)-0.0 returns 0L. As these methods are meant to be safer casts, I think we should follow the JLS as closely as

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-05 Thread Michael Hixson
On Thu, 5 May 2022 10:11:05 GMT, Raffaello Giulietti wrote: > Add a family of "safe" cast methods. This PR also solves [JDK-8154433](https://bugs.openjdk.java.net/browse/JDK-8154433), though you went the other way on -0.0. - PR: https://git.openjdk.java.net/jdk/pull/8548

Re: RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-05 Thread Raffaello Giulietti
On Thu, 5 May 2022 10:11:05 GMT, Raffaello Giulietti wrote: > Add a family of "safe" cast methods. For an in-depth rationale, please refer to the issue (Enhancement). Note that the method names are, in fact, of the to*Exact rather than of the as*Exact form - PR: https://git.openj

RFR: 8279986: methods Math::asXExact for safely checked primitive casts

2022-05-05 Thread Raffaello Giulietti
Add a family of "safe" cast methods. - Commit messages: - 8279986: methods Math::asXExact for safely checked primitive casts - 8279986: methods Math::asXExact for safely checked primitive casts - 8279986: methods Math::asXExact for safely checked primitive casts Changes: https://g