DIP1028 and phobos

Steven Schveighoffer schveiguy at gmail.com
Sat May 23 12:00:40 UTC 2020


On 5/23/20 1:16 AM, Uknown wrote:
> With DIP 1028 finally being accepted, we now have @safe by default. If 
> we ignore the extern function controversies around the DIP for a second, 
> its worth looking at some of the other issues that DIP 1028 brings.
> 
> Consider the following trivial code:
> 
> void main(string args[]) @safe
> {
>      import std.stdio : stderr;
>      if (args.length != 2) {
>          stderr.writeln("usage: %s filename");
>          return;
>      }
> }
> 
> This does not compile, because stderr, stdin and stdout are all marked 
> @system. Technically, I understand why they are marked @system, but 
> practically, most people would expect something like this to Just Work, 
> without having to mark main @system, or use () @trusted {...}();

They shouldn't be @system. It's probably just an example of lazy 
programmers not fixing stuff that hasn't complained yet.

> 
> I think given DIP 1000 and DIP 1028, its worth looking into phobos and 
> reviewing other "trivial" stuff that should work with @safe but doesn't, 
> and coming up with ways to fix them.

For sure, we will not be turning on safe by default until Phobos and 
druntime are made to work with it.

-Steve



More information about the Digitalmars-d mailing list