@safe by default and old code

Dylan Graham dylan.graham2000 at gmail.com
Fri Aug 6 01:19:34 UTC 2021


On Friday, 6 August 2021 at 00:30:36 UTC, Kirill wrote:
> I've heard that there are plans to make D `@safe by default`.

The question pops up every few months, but I don't think anything 
has been decided.

> Then the question that pops into my head is what will happen to 
> all the code that was written before it and once it is 
> implemented?
>
> Will it require a rewrite?

I assume that there will be a deprecation phase before that is 
implemented so that codebases and dependencies have ample time to 
adjust to upcoming changes, without breaking them in the meanwhile

> How should the code be written from now on to avoid this?

Declaring `@safe:` at the top of your module sort of does the 
same thing. Try to use safe D where ever you can, and mark other 
things as `@trusted` and `@system` as appropriate.

@more experienced D users, feel free to correct me.


More information about the Digitalmars-d mailing list