Using closure in function scope to make "real" private class members

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Jun 6 08:51:44 UTC 2022


On Monday, 6 June 2022 at 04:34:23 UTC, forkit wrote:
> An option to bring back an actual class type.

What do you mean here?

Btw, one advantage of having module-level private is that D 
classes have "invariant checks". If you can prove that all the 
functions in the module uphold the class-invariant, and if the 
invariant only touches private fields, then you can remove the 
invariant check.

There is nothing wrong with having @private in addition, but the 
main issues is that the complexity of D source code is going in 
the wrong direction. Having 4 protection levels is perhaps more 
of a disadvantage than an advantage.

The problem is not this "one addition". The problem is the 100 
other "one additions". Everybody has their own "just this one" 
and that is how D is accumulating more and more complexity.



More information about the Digitalmars-d mailing list