psychoticRabbit wrote:

On Tuesday, 13 March 2018 at 01:39:13 UTC, Jonathan M Davis wrote:

private is private to the module, not the class. There is no way in D to restrict the rest of the module from accessing the members of a class. This simplification makes it so that stuff like C++'s friend are unnecessary. If your class in a separate module from main, then main won't be able to access its private members.

- Jonathan M Davis

Mmm.. I don't think I like it.

I feel you should be able to make a member of a class, private, regardless of where the class is located. This seems to break the concept of class encapsulation.

No. I don't like it at all.

just stop thinking in C/C++ "#include" terms. there, you have no other ways to restrict data access, so they were forced to make it broken, and then introduce "friends" just to workaround the fact that there are no modules in C++.

instead, start thinking with modules in mind. module is THE unit of incapsulation. there is nothing wrong in isolating class or two in a module. then, to make imports manageable, either create a package of that, or just a dummy module that does `public import xxx;` for everything.

Reply via email to