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

Basile B. b2.temp at gmx.com
Mon Jun 6 09:39:30 UTC 2022


On Monday, 6 June 2022 at 08:51:44 UTC, Ola Fosheim Grøstad wrote:
> 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.

reminder: we have [already 5]

>
> 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.

[already 5]: 
https://dlang.org/spec/attribute.html#visibility_attributes


More information about the Digitalmars-d mailing list