Feedback on Átila's Vision for D

Nicholas Wilson iamthewilsonator at
Sat Oct 19 12:23:36 UTC 2019

On Saturday, 19 October 2019 at 11:46:21 UTC, drug wrote:
> I agree that in D having private to be in fact moduleprivate is 
> unusual comparing to C++ for example.

In C++ you have no modules (modulo recent activity) and so the 
class is the only unit of encapsulation that there is apart from 
namespaces. In Java there you can only have a single class per 
module so module private and class private are the same thing 
(possibly modulo inner classes? idk I don't Java).

In D you can't not use modules _and_ you can have multiple 
declarations per module _and_ there is only one private (and no 
friend, or alternately everything in the modules are friends) so 
the line has to be drawn somewhere.

> But is it really bad in practice?

IME, no. If your module is big enough that you can't keep all of 
it in you head and you start calling implementation details of 
your classes _by accident_ then either:
a) name your implementation details so they stand out so you 
don't call by accident (e.g. a._something() )
b) split up your module into a package so that it fits in your 
head, this will (probably) cause you to not be able to call the 
implementation details at all, and will thus cause you to have to 
think about the organisation of you package (which is probably a 
good thing).

More information about the Digitalmars-d mailing list