nothrow by default

Walter Bright newshound2 at digitalmars.com
Sun Jan 5 09:52:55 UTC 2020


On 1/4/2020 3:06 PM, Adam D. Ruppe wrote:
> On Saturday, 4 January 2020 at 21:38:53 UTC, Walter Bright wrote:
>> The short rationale is that exceptions being a "pay only if you use them" is a 
>> complete fraud. They're expensive to support, meaning performance programs use 
>> other ways of signalling errors and use nothrow.
> 
> There's more to code than performance. D is an all-purpose language.
> 
> But anyway, D still allows throwing from nothrow, but only if it is the Error 
> class. I presume that would not change.

I've been thinking about getting rid of Error entirely, and instead using a 
scheme that calls a user-supplied function when things go that wrong. (Error is 
non-recoverable.)


> But my worry on nothrow by default in general is then more D code will just 
> become fragile since other error methods have historically meant they simply get 
> ignored and not even reported.... barring something like those newfangled type 
> based systems that's probably what we'd become too.

It shouldn't become fragile, because the compiler will reject nothrow code on 
the call stack if an exception is thrown.


More information about the Digitalmars-d mailing list