Value Type Exceptions
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Sep 22 15:37:04 UTC 2024
On 22/09/2024 10:25 PM, IchorDev wrote:
> On Thursday, 19 September 2024 at 18:31:02 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> - Did I mention the throw set is inferred? Sadly it cannot shrink down
>> to the empty set due to virtual functions/function pointers, but we
>> could change that with an edition if it's desirable to do so.
>>
>> ```d
>> int toCall() @throw(:FailedToDecodeUTF) {
>> throw :FailedToDecodeUTF;
>> }
>>
>> int caller() /* @throw() */ {
>> int result;
>>
>> try {
>> result = toCall();
>> } catch(:FailedToDecodeUTF) {
>> result = 0xDEADBEEF;
>> }
>>
>> return result;
>> }
>> ```
>
> But if `caller` is manually marked nothrow then it wouldn’t be a
> compiler error anymore just because you didn’t catch `Exception`?
``nothrow`` is equivalent to the empty set ``@throw()``, so in the
example it is ``nothrow``.
So I'm not sure what you are asking?
> Also, could you elaborate on what `:FailedToDecodeUTF` is in this
> situation? Like, what exactly is it a member of?
The sumtype that represents the exceptions, specifically a tag that has
no payload.
See my sumtype proposal, this would use that under the hood.
More information about the dip.ideas
mailing list