Why is D unpopular

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Jun 13 12:34:56 UTC 2022


On Monday, 13 June 2022 at 12:03:10 UTC, Max Samukha wrote:
> And the reason is the private member of the class shouldn't be 
> accessible outside its declaration scope in the first place. 
> Module-level 'private' is dysfunctional by design.

It can be fixed, but I personally prefer granting other entities 
«roles».

C++ friend-mechanism is one variant of granting "roles". For 
instance if you make the class MedicalRole a friend of the class 
Brain then you can make BrainSurgeon a subclass of MedicalRole 
which grants the BrainSurgeon access to the internals of Brains. 
Since C++ has multiple inheritance it follows that you can design 
your own role-granting regime in C++ if you want to.

(I personally prefer to only grant access to individual functions 
because it is tighter, but the concept of class based roles is 
easier to deal with when debugging/remodelling than the concept 
of package.)






More information about the Digitalmars-d mailing list