On Wednesday, 16 May 2018 at 02:15:45 UTC, KingJoffrey wrote:

"The unit of object encapsulation in D is the class." - page 175, The D Programming Language, 2010, Andrei Alexandrescu.

What it really should have included, locally, within that same section, is the implications of this 'encapsulation' with regards to how 'facebook like friendship' is a core design component of the D module.

i.e, on the next line, Andrei could have continued..

"However, if your class is contained within a module, then this encapsulation barrier kinda breaks down, because everything in the module becomes a friend of that class, whether you like it or not. You have no say in the matter. If you don't like it, fine, but that's how D does things, so just be careful what you put in a module".

Although, to be fair to Andrei, once you get to page 200 (25 pages after the above comment about class encapsulation), you do, finally, get some clarification:

"In all contexts, private has the same power: it restricts symbol access to the current module (file). This behavior is unlike that in other languages, which limit access to private symbols to the current class only. ... If class-level protection is needed, simply put the class in its own file."

Reply via email to