how to make private class member private
psychoticRabbit
meagain at meagain.com
Tue Mar 13 09:14:26 UTC 2018
On Tuesday, 13 March 2018 at 08:44:48 UTC, Mike Parker wrote:
>
> Any new keywords, or reuse of existing keywords, does make the
> language more complex. Everything that is added must have a
> reason. Private is module level because friend is so common in
> C++, i.e. people find it useful and it would be great to
> support something similar in D. Making modules the lowest level
> of encapsulation does that without the need for an extra
> keyword for friends while still maintaining a strict border
> between external and internal APIs. Moreover, it restricts
> friends to the same module, easing the maintenance burden and
> decreasing the chance of error. It was a great decision.
yeah, I probably agree that it's a good decision, when the module
is the boundary.
(aka so-called 'principled' violation of encapsulation)
what I don't like, is that I have no way at all to protect
members of my class, from things in the module, without moving
that class out of that module.
D wants me to completely trust the module, no matter what.
That's make a little uncomfortable, given how long and complex
modules can easily become(and aleady are)
More information about the Digitalmars-d-learn
mailing list