[OT] - C++ exceptions are becoming more and more problematic

IGotD- nise at nise.com
Wed Feb 23 16:20:43 UTC 2022


On Wednesday, 23 February 2022 at 16:11:45 UTC, rikki cattermole 
wrote:
>
> ``@throws(Exception)`` would be equivalent to what D functions 
> without ``nothrow`` are today by default. ``@throws()`` would 
> be equivalent to ``nothrow``.
>
> ``@throws(Struct)`` would only allow the Struct to be thrown 
> from a function.
>

I'm really against "manually" declaring which exceptions a 
function throws. It will quickly become unmaintainable as people 
will forget which exceptions that are thrown and which are not. 
This means that the compiler must give an error when the 
exception was thrown which wasn't declared. Also warn about 
exceptions not thrown when they are declared so the compiler must 
track the exceptions anyway. Let the compiler do it, that's what 
computers are for. Also let's be conservative with @badging.


> I would like to hear other opinions especially Walter's since I 
> don't think he has commented on value type exceptions 
> design-wise recently.

Walter said that exceptions are on the way out, because of the 
optimization problem which this article also described. He has 
not presented an alternative error handling mechanism.


More information about the Digitalmars-d mailing list