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

jmh530 john.michael.hall at gmail.com
Sat Apr 11 18:20:54 UTC 2020


On Saturday, 11 April 2020 at 07:31:53 UTC, Walter Bright wrote:
> [snip]
>> 
>> I recommend that the DIP proposes to avoid this problem 
>> somehow. One possibility is proposing an alternative to 
>> `@system:` that does not apply to templates. Another is 
>> proposing that by default, regular functions would have their 
>> safety inferred the same way it's inferred for templated 
>> functions (thanks to Vladimir Panteleev for this idea 
>> -wouldn't have occured to me).
>
> The DIP says: "Functions such as template functions, nested 
> functions, and lambdas that are not annotated currently have 
> their @safe / @system attribute inferred. This behavior will 
> not change." which takes care of this.

I do not believe this addresses the concerns brought up...

Suppose you have some code like

void systemOriginally(int x) {}
//more code
void inferSafety(T)(T x) {}

originally. Then the default changes to @safe, but the maintainer 
adds @system to the top as in

@system:
void systemOriginally(int x) {}
//more code
void inferSafety(T)(T x) {}

This is not an issue for systemOriginally, but inferSafety is no 
longer inferred. The @system at the top overrules it. You 
couldn't just put a @system: at the top. You would need a system 
block that covers systemOriginally and not inferSafety.



More information about the Digitalmars-d mailing list