Why does `ScopedValue.where(SCOPE_VALUE, val).call()` throw Exception?

Glavo zjx001202 at gmail.com
Thu Apr 13 12:05:19 UTC 2023


Unfortunately, such an interface is not good enough for functions that may
throw multiple types of exceptions.

It would be great if Java supports using union types in more places.

Glavo

On Thu, Apr 13, 2023 at 7:41 PM Holo The Sage Wolf <holo3146 at gmail.com>
wrote:

> I want to add an argument to push more the j.u.f.exceptionally approach I
> suggested.
>
> Just today someone in Reddit pointed out how String Templates have an
> inconsistent semantics with the j.u.function package, as they have the
> interface:
>
>     @FunctionalInterface
>     public interface Processor<R, E extends Throwable> {
>         R process(StringTemplate st) throws E;
>     }
>
> If we had a j.u.f.exceptionally package, then not only it will be more
> consistent across the the standard library, it will unify a lot of
> functional interfaces:
>
> import java.util.function.exceptionally.Function;
> [...]
>     @FunctionalInterface
>     public interface Processor<R, E extends Throwable> extends Function<StringTemplate, R, E> {
>         R apply(StringTemplate st) throws E; // luckily, the semantics of the word "apply" also fits for activating a processor
>     }
>
>
> On Thu, Apr 13, 2023 at 2:30 PM Holo The Sage Wolf <holo3146 at gmail.com>
> wrote:
>
>> > Do you have a way to help me find that Amber discussion?
>>
>> Here is the start of the thread:
>> https://mail.openjdk.org/pipermail/amber-dev/2023-March/007849.html
>>
>> But the relevant part (the discussion I had with Brian Goetz) starts
>> here: https://mail.openjdk.org/pipermail/amber-dev/2023-March/007858.html
>>
>> The end conclusion was what you probably expect it to be, but I think it
>> is important discussion to have and I hope that when few features will
>> finally finalize and there will be a bit of free time to the team the
>> discussion will start to be active again
>>
>> On Thu, Apr 13, 2023 at 1:45 PM Andrew Haley <
>> aph-open at littlepinkcloud.com> wrote:
>>
>>> On 4/13/23 11:23, Holo The Sage Wolf wrote:
>>> > As a side note, generally I'm a bit disappointed
>>>
>>> You and everybody else.
>>>
>>> > from the state of
>>> > exceptions with generics in Java, not too long ago I talked about it
>>> in (I
>>> > believe) the Amber mailing list about possible improvements in the
>>> future.
>>>
>>> I've spent a fair bit of time discussing this kind of thing with Brian
>>> Goetz
>>> et al., and it's just a very hard problem. Any "Hey, let's do this!"
>>> probably
>>> will have some unfortunate side effects somewhere.
>>>
>>> Do you have a way to help me find that Amber discussion?
>>>
>>> --
>>> Andrew Haley  (he/him)
>>> Java Platform Lead Engineer
>>> Red Hat UK Ltd. <https://www.redhat.com>
>>> https://keybase.io/andrewhaley
>>> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
>>>
>>>
>>
>> --
>> Holo The Wise Wolf Of Yoitsu
>>
>
>
> --
> Holo The Wise Wolf Of Yoitsu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230413/8178f1bb/attachment.htm>


More information about the loom-dev mailing list