nothrow by default

Guillaume Piolat first.last at gmail.com
Thu Jan 9 12:59:45 UTC 2020


On Thursday, 9 January 2020 at 10:32:25 UTC, Jonathan M Davis 
wrote:
>
> I wouldn't mind us getting rid of Error in favor of killing the 
> program on the spot, since that's actually better for 
> debugging, and it avoids the whole argument about whether it's 
> okay to catch Errors.

Yes please!

> However, Exceptions are for runtime conditions that aren't 
> necessarily a bug, and they can often be recovered from. So, 
> being able to throw Exceptions is extremely useful, and the 
> fact that they don't force you to check for error conditions 
> everyewhere and instead just handle them in the spots where it 
> makes sense to handle them makes the code _way_ cleaner.
>
> IMHO, having nothrow be the default would be terrible, and 
> trying to treat exceptions as a legacy feature would be even 
> worse.
>
> - Jonathan M Davis

+1, and I would add that when writing modern C++11 with only 
linear types, exceptions + RAII quickly appear as the _only way_ 
to have correct desctruction teardown in error conditions (the 
least tested pathes).
Anything else is just bring undetected errors in error paths, 
like in C. GC only catches non-reclaimed memory...


More information about the Digitalmars-d mailing list