DIP 1029---Add throw as Function Attribute---Community Review Round 1

Walter Bright newshound2 at digitalmars.com
Tue Jan 14 22:30:40 UTC 2020

On 1/14/2020 8:44 AM, Dukc wrote:
> This would be a step forward, of course. But would not it be better to kill the 
> one-way attribute problem in one go -meaning, making an antiattribute for `pure` 
> and `@nogc` too?

Because for the anti-nothrow we already have a trivial solution staring us in 
the face, we just have to pick it up. I have no explanation for not seeing the 
obvious before.

> In addition, I suggest that there should be a way to use 
> [`pure:`/`nothrow:`/`@nogc:`/`@safe:`/their antiattributes] so that they only 
> apply when attributes are not inferred - not for templated functions. This would 
> also remove a big obstacle from front of DIP1028, as one could just mark the 
> whole module `@system` with one statement without killing template `@safe` or 
> `@live` inference.

It turns out that there's another "attribute" under the covers - the default. 
Only when an attribute is the default does inference come into play. Hence, when 
"nothrow" becomes the default, there will be actually three states - throw, 
nothrow, and default.

It works out rather nicely. It's in play for safe/trusted/system already, and 
has been since the beginning.

More information about the Digitalmars-d mailing list