A proposal: Sumtypes

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Fri Feb 16 09:53:41 UTC 2024


On 16/02/2024 10:19 PM, Kagamin wrote:
> I refer to the idea of implementation of error handling with return 
> types, possibly nogc. Is it not supposed to involve sumtypes somehow?

If there is no language level support for it, then yes you will need to 
declare the sumtype explicitly.

If there is, which my proposal for value type exceptions provide, 
inference or ``@throws(Exception, MyException)`` will do it, without the 
need of a sumtype declaration.

Note for language level support, throw and catch would add and remove 
automatically from the set, so sumtypes are only of note if you catch all.


More information about the Digitalmars-d mailing list