New candidate JEP: 506: Scoped Values
Alan Bateman
alan.bateman at oracle.com
Tue Apr 15 17:58:52 UTC 2025
On 15/04/2025 17:17, Adam Gent wrote:
> For those that do not want to go to reddit the gist is I think if we do not allow null in a Scoped Value it makes the API less bloated and easier to use with pattern matching.
Just to add to Andrew's comments. If you think of a scoped value an
implicit parameter then it would be surprising to allow an explicit
parameter be null but not an implicit parameter. As it happens, the
first usage of ScopedValue API was Subject which does bind to a null
value. In any case, as Andrew said, once we have null-restricted types
then a nullness marker can be used. The orElse(V) method doesn't allow
null so it might become orElse(V!). There may be an argument to add an
orNull() for cases where code wants to gracefully handle the case that
it is called without a binding and not use a sentinel, that hasn't been
ruled out.
-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20250415/43680e48/attachment.htm>
More information about the loom-dev
mailing list