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

Walter Bright newshound2 at digitalmars.com
Tue Jan 14 20:35:44 UTC 2020

On 1/14/2020 7:18 AM, Arine wrote:
> Why isn't this being fixed so that `nothrow{}` then applies to `S2.foo()`? Why 
> is it even part of the rationale if there's no intention to fix this?

Because it's the way the other attributes work. Trying to change this would be 
very disruptive. The reason it works this way is it is unkind to the purpose of 
scoping. If the attributes passed into nested scopes, then you'll pretty much 
force a coding guideline to "list all the attributes needed at the beginning of 
each scope" so it won't silently break when someone adds a:


at the top.

> If you are going to add `throw` why aren't the rest of the attributes getting 
> inverses? Pure? @nogc? etc...

Since we already have a keyword available, it makes sense to use it. 
throw/nothrow nicely complement each other.

> Just adding `throw` 
> isn't a significant/meaningful enough change on it's own, if you look solely at 
> this DIP.

It does add value on its own, as the user can now decide what his default is and 
override it as necessary. The value isn't huge, but the change is trivial, so 
the cost/benefit ratio is still good.

More information about the Digitalmars-d mailing list