Non-techincal brain, is @safe by default good or not?

Tove tove at fransson.se
Thu May 28 10:43:13 UTC 2020


On Thursday, 28 May 2020 at 10:28:47 UTC, Mathias LANG wrote:
> ```
> import std.json;
>
> struct MyCustomType
> {
>     public string toString () const @system { return null; }
>     alias toString this;
> }
>
> void main () @system
> {
>     JSONValue json;
>     MyCustomType ilovedlang;
>     json = ilovedlang;
> }
> ```
>
> Results in:
> ```
> /usr/local/opt/dmd/include/dlang/dmd/std/json.d(459): Error:

Holy insanity... 100% of my D code is @system, I was thinking I 
can avoid this entire DIP by, simply adding "@system:" in my 
files and live happily ever after, so I kept quiet. Now I see why 
some people was asking for D3.

The Top-1 reason why my code is @system is because D doesn't 
allow function local "ref". So I use pointers instead, it's 
pretty nice since you don't need to use "->".

Maybe something like this could work?
@system import std.json;

Or a ton of fixes is needed in phobos and many 3rd-party 
libraries also...



More information about the Digitalmars-d mailing list