DIP 1029---Add throw as Function Attribute---Community Review Round 1
Jan Hönig
hrominium at gmail.com
Wed Jan 22 21:11:30 UTC 2020
On Thursday, 16 January 2020 at 20:19:24 UTC, Arine wrote:
> 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.
(I am in the @safe and throw camp as default.)
I really like Adam's ideas about the attributes:
http://dpldocs.info/this-week-in-d/Blog.Posted_2020_01_13.html
That way we can easily get code, how we like to, without much
pollution (i would not consider one line in a module a
pollution), no matter what the defaults are.
This DIP is just a little step, which might or might not go in
any direction afterwards.
More information about the Digitalmars-d
mailing list