DIP 1028---Make @safe the Default---Community Review Round 1

ag0aep6g anonymous at example.com
Thu Jan 2 12:23:54 UTC 2020


On 02.01.20 12:10, bachmeier wrote:
> If I want to make my code compile, I'd be forced to declare a function 
> @trusted *even if it shouldn't be*. In other words, if we go down this 
> road, @trusted loses its meaning. If I mark it @system, that doesn't 
> really help, because my code still isn't going to compile.

Yes, you shouldn't blindly slap @trusted on your non- at safe functions.

But you *can* blindly slap @system on them. Non-annotated functions are 
already @system by default; you're just making it explicit. Your code 
should compile the same as today.

> Perhaps someone can explain where I'm wrong. If I'm correct, then it 
> would make more sense to declare at the top of a file that this is 
> legacy code and thus treated as @trusted unless marked otherwise.

There's not really a way to do it for a whole file, but with `@system:` 
and `@system { ... }` the busywork might be tolerable. Though I would 
consider it better practice to mark each function individually.

And legacy code should be treated as @system, not as @trusted.


More information about the Digitalmars-d mailing list