Feedback Thread: DIP 1028--Make @safe the Default--Final Review
Walter Bright
newshound2 at digitalmars.com
Sat Apr 11 07:31:53 UTC 2020
On 3/31/2020 4:08 PM, Dukc wrote:
> On Wednesday, 25 March 2020 at 07:03:16 UTC, Mike Parker wrote:
>> [snip]
>
> There is still this issue, that was brought up at previous review also:
>
> Consider large amounts of legacy code modules that mix a lot of templated and
> non-templated functions. Majority of the non-templated functions are not
> `@safe`, but a many templates rely on inferring safety based on their arguments.
> The code is already tested to be reliable, and refactoring it to be @safe would
> not be worth it.
>
> This DIP, as it currently stands, would force the maintainers to add `@system`
> function by function to the codebase, which can be somewhat large effort. If the
> maintainers could just add `@system:` to top of each module, the migration
> effort would be greatly reduced. However, they can't because they rely on the
> templates in the modules inferring `@safe` based on the arguments.
>
> 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.
More information about the Digitalmars-d
mailing list