nothrow by default

Guillaume Piolat first.last at
Mon Jan 6 10:05:41 UTC 2020

On Monday, 6 January 2020 at 06:58:34 UTC, Paul Backus wrote:
> On Monday, 6 January 2020 at 03:13:09 UTC, Guillaume Piolat 
> wrote:
>> On Saturday, 4 January 2020 at 16:05:10 UTC, Steven 
>> Schveighoffer wrote:
>>> Just wanted to bring this up, and not muddy the other thread.
>>> What do you put if you throw? @safe by default has 
>>> alternatives. nothrow does not. Are we going to get a new 
>>> keyword/uda?
>>> -Steve
>> WHY would nothrow by the default in the first place?
>> Exceptions are about the best error handling mechanism and 
>> there is no better altnernative in D.
> `nothrow` by default doesn't stop you from using exceptions, it 
> just forces you to either catch them or mark your function as 
> throwing.

What do you think people will do:
A - handle the exception correctly at the right place and mark 
the whole chain of calls as `throws`
B - mark a single function as `nothrow` and catch the Exception 
with a dummy handler

B is dangerously easier to do.

Also the statu quo isn't so bad: an unhandled exception crash, 
which is an unrecoverable error, as good as an 
assertion-in-release. Not handling one is a bug, and it acts like 

How many times will D break all code in the future?

More information about the Digitalmars-d mailing list