Discussion Thread: DIP 1028--Make @safe the Default--Final Review
Steven Schveighoffer
schveiguy at gmail.com
Fri Apr 3 14:49:41 UTC 2020
On 4/3/20 10:39 AM, rikki cattermole wrote:
> On 04/04/2020 12:27 AM, John Colvin wrote:
>> On Friday, 3 April 2020 at 10:15:35 UTC, Mathias LANG wrote:
>>> On Friday, 3 April 2020 at 09:50:39 UTC, Walter Bright wrote:
>>>> On 3/27/2020 5:32 AM, aliak wrote:
>>>>> So my understanding is if extern (C) is applied on a function
>>>>> declaration, then an annotation is explicitly required?
>>>>
>>>> No. Without an explicit annotation, it will be the default (@safe).
>>>
>>> And absolutely no one else thing it's a good idea, because it's
>>> essentially slapping `@trusted` on all `extern(C)` functions.
>>
>> I think I agree. I'd sooner have no default at all on functions
>> without implementation (i.e. you have to explicitly say @system).
>
> Unless the compiler has checked the body for @safe, it cannot be assumed
> to be @safe. As that breaks its guarantees.
>
> So I am on the side of, without body, default = @system.
For extern(D) functions, the mangling takes care of the problem. I would
say everything that doesn't mangle @safe-ty into the name, assume system
(breaks less code but inconsistent/less clear) OR error (requires
annotation, so breaks code, but is clearer).
Basically, this only comes into play for .di files.
-Steve
More information about the Digitalmars-d
mailing list