how to make private class member private
psychoticRabbit
meagain at meagain.com
Sat Mar 17 23:54:22 UTC 2018
On Saturday, 17 March 2018 at 21:33:01 UTC, Adam D. Ruppe wrote:
> On Saturday, 17 March 2018 at 21:22:44 UTC, arturg wrote:
>> maybe extend that to a list of types?
>
> this is basically what C++ friend does and D was trying to
> avoid the complexity of
Really, the complexity of 'friend' comes from people abusing it.
In D, I would prefer no breaking change here. Leave private as it
is.
Just a simple attribute that only applies within a class, and
only to private members within that class.
@strictly private string firstName_;
Nothing outside of the class, not even the module, can access
this now. It's all encapsulated.
It breaks nothing (AFAIK).
It's very clear what the intention is here.
It's an easy attribute to remember.
It restores the principle of class enscapsulation within a
module, for when it's really needed.
Now D programmers would have the best of both worlds.
More information about the Digitalmars-d-learn
mailing list