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

Holo The Sage Wolf holo3146 at gmail.com
Thu Apr 13 12:13:03 UTC 2023


You are correct

> As a side note, generally I'm a bit disappointed
> from the state of
> exceptions with generics in Java

I recommend reading what I said in the Amber list (the second link I posted
few messages ago on this thread), I gave an example of how it is useful,
and how union types will be harmful in the generic level without some
destructive pattern.

The interfaces I suggested are the best we can do as of today with either
uniform Monadic type for exceptions, or better Polymorphic Effects (and if
you read my messages from the amber list you would find some my reasoning
to think the Polymorphic Effects are better)

I think that adding those new interfaces will encourage more use of
exceptions in lambdas which in turn push forward the discussion of finally
addressing this monster called error handling in a more uniform consistent
way



On Thu, Apr 13, 2023, 15:05 Glavo <zjx001202 at gmail.com> wrote:

> 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/dce4696f/attachment-0001.htm>


More information about the loom-dev mailing list