Discussion Thread: DIP 1028--Make @safe the Default--Final Review

Steven Schveighoffer schveiguy at gmail.com
Fri Mar 27 04:07:53 UTC 2020


On 3/26/20 11:44 PM, Mathias Lang wrote:
> On Friday, 27 March 2020 at 02:35:56 UTC, Vladimir Panteleev wrote:
>> On Friday, 27 March 2020 at 02:31:13 UTC, Vladimir Panteleev wrote:
>>> This applies to extern(D) declarations, too. Effectively, this would 
>>> mean that functions with a body won't need a @safe annotation, but 
>>> functions without a body will require it. However, I think this is a 
>>> more correct solution despite this issue.
>>
>> An afterthought. Because safety is part of D mangling, body-less 
>> extern(D) declarations could be assumed to be @safe. A mismatch 
>> (assumption of @safe but a @system implementation) will result in a 
>> linker error.
>>
>> This applies to all mangling schemes which can represent @safe, which 
>> is only extern(D) at the moment. So, if any calling convention would 
>> be special in this regard, it would be extern(D).
> 
> Linker error are some of the most unfriendly way to do diagnostic.
> Having all declarations without definitions needing to be explicitly 
> annotated is IMO much better.
> There aren't that many places out there where such a pattern is used 
> anyway.

How does this fix the problem though? Today, if you use a wrong type, 
you get a linker error. I don't see why that's less confusing than not 
marking a function @system. And what if you mark it @system, but it's 
really @safe? Linker error. Just another thing to mess up.

I would say extern(D) functions are fine as prototypes without extra 
markings.

-Steve


More information about the Digitalmars-d mailing list