Extending D's support for object-oriented design with private(this)

NotYouAgain NotYouAgain at gmail.com
Fri Apr 26 05:48:03 UTC 2024


On Thursday, 25 April 2024 at 09:31:06 UTC, Kagamin wrote:
>...
> Nested classes.

I believe that private(this) needs to always be consistent with 
its meaning.
Altering its meaning for nested classes would not be appropriate.
There is no code breakage. One simply can choose not to use 
private(this).

class Outer
{
     private(this) int m;

     class Inner
     {
         private int foo()
         {
             return m;   // Error: class `test.Outer` variable `m` 
is not accessible

         }
     }

}


More information about the dip.ideas mailing list