Preparing for the New DIP Process

FairEnough FairEnough at gmail.com
Sat Jan 27 22:33:01 UTC 2024


On Saturday, 27 January 2024 at 19:58:55 UTC, Jordan Wilson wrote:
>
> ..
> I believe we are now in the "there is nothing more to be said" 
> territory (just for the record, I think we both agree the 
> feature is good, I just don't think the feature is necessary at 
> all...nice-to-have at best. I suspect we'll agree to disagree).
>
> Jordan

It *is* necessary, if you are like me and want to design types 
upfront so you don't have to read all the code in the module to 
see which parts of that type are touched outside of the type, and 
which are not.

class C
{
     private int x;

     private(this):
         int y = 1;
         int w, z;

     public void test()
     {
       y = y + 4;
     }

     public int getY()
     {
         return y;
     }
}

unittest
{
     auto c = new C();

     import std;

     writeln(__traits(getVisibility, C.y));
     static assert(__traits(getVisibility, C.y) == 
"private(this)");

     c.x++; // allowed
     //c.y++; // not allowed
     //c.w++; // not allowed
     //c.z++; // not allowed

     c.test;
     writeln(c.getY);
}



More information about the Digitalmars-d-announce mailing list