RFR: JDK-8286666: JEP 429: Implementation of Scoped Values (Incubator) [v6]
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Nov 15 21:31:37 UTC 2022
On Tue, 15 Nov 2022 20:26:37 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> src/jdk.incubator.concurrent/share/classes/jdk/incubator/concurrent/ScopedValue.java line 613:
>>
>>> 611: * @return the value of the scoped value if bound, otherwise {@code other}
>>> 612: */
>>> 613: public T orElse(T other) {
>>
>> From an API perspective, wouldn't return `Optional` a more consistent choice? `Optional` has all methods we need to deal with this kind of stuff...
>
> This comment is on orElse but I suspect you are suggesting that get() be changed to return Optional. I think we'll need to get more feedback/usage of this API before re-visiting that.
Yes, my comment was really on `get` - that said, I note that saying get().get() would look odd (but maybe finding some other name for `ScopedValue::get`, such as `find` might work)
-------------
PR: https://git.openjdk.org/jdk/pull/10952
More information about the core-libs-dev
mailing list