On Wed, 16 Nov 2022 12:11:45 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> wrote:
>> We expect isBound() will be used a lot and I think that is clearer (and >> cheaper) than find().isEmpty(). >> >> Time will tell on orElse/orElseThrow and whether they should be replaced >> with an Optional view. That is, I think your comments mostly apply to those >> two methods rather than get/isBound. > > Note that `isBound` can also be explained as just a shorcut for > `find().isEmpty()`. That is, I'm not really suggesting to drop sugary methods > from the API. But by exposing the optional nature of the result, the API > might end up being more composable. > > But, as you said, we don't have to decide now. Note that `ScopedValue` can currently be bound to `null`, but by using `Optional`, there would be no way to differentiate an unbound `ScopedValue` from one bound to `null`. ------------- PR: https://git.openjdk.org/jdk/pull/10952