www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DIP1028 and phobos

reply Uknown <sireeshkodali1 gmail.com> writes:
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 {...}();

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.
May 22
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
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
May 23
parent Uknown <sireeshkodali1 gmail.com> writes:
On Saturday, 23 May 2020 at 12:00:40 UTC, Steven Schveighoffer 
wrote:
 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.
They were marked system because the are global and apparently not thread safe in some cases. I think there was a PR to fix it a long time ago, but it was put on hold for shared to be fixed
 
 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
Yeah, I just think its worth documenting all these, so its easy to see what's still to be done. Some of the fixes might be easy, so it could be even be good "beginner patches" stuff
May 23