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

Arine arine123445128843 at gmail.com
Thu Jan 16 20:19:24 UTC 2020

On Thursday, 16 January 2020 at 08:04:35 UTC, Walter Bright wrote:
> On 1/15/2020 7:26 AM, Arine wrote:
>> I'm completely blown away, you don't even know that @safe 
>> passes through to the next scope?
> My mistake. What actually happens is here:
>     sc2.stc &= STC.safeGroup;
> https://github.com/dlang/dmd/blob/master/src/dmd/aggregate.d#L136
> where the storage class passed from the outer scope to the 
> struct/class scope is zeroed out except for 
> @safe/@trusted/@system.
> So @safe "flows through" to the struct scope, while nothrow, 
> pure, @nogc, etc., do not.

So when you were proposing @system: as a solution to the change 
to default of @safe, you thought you had to add @system to the 
top of every struct, and that's the solution you promoting as a 
best practice?

Honestly I'd prefer rebuttal about my point regarding defaults. 
If the defaults aren't what you want them to be, the language 
forces you to pollute your code with `attributes:` because they 
don't flow into the next scope. If that's the only reason, and 
there's no other reason why it behaves this way. It'd be best to 
change it so that the user the option to choose what is best for 
them. If they feel it is best add it to every scope, that's their 
option to. But right now it's forced onto us.

More information about the Digitalmars-d mailing list