Why does `ScopedValue.where(SCOPE_VALUE, val).call()` throw Exception?
Kasper Nielsen
kasperni at gmail.com
Thu Apr 13 08:08:56 UTC 2023
On Wed, 12 Apr 2023 at 18:20, Andrew Haley <aph-open at littlepinkcloud.com> wrote:
>
> On 3/23/23 16:59, Holo The Sage Wolf wrote:
> > A possibly better solution is to create:
> >
> > ```java
> > @FunctionalInterface
> > interface GCallable<R, E extends Throwable> {
> > R call() throws E;
> > }
> > ```
> > And use this interface.
> > It will require changing the signature of `Carrier#runWith` (and hence
> > modifying `JVM_FindScopedValueBindings`) and of 3 methods in
> > `ScopedValueContainer` (alternatively only changing the signature of
> > `Carrier#runWith` and the implementation of `ScopedValueContainer#call`),
> > but everything else could be left unchanged, and letting Java infer the
> > exception needed.
>
> I can see the logic in doing this, and it would have been nice had Callable
> been declared this way, but I don't think I can get away with adding yet
> another public Functionalnterface to the Callable and Supplier set.
Not adding more interfaces would of course be preferable.
But I would argue that not providing an easy way for working
with Throwables for such a low-level tool is the worse solution.
/Kasper
More information about the loom-dev
mailing list