how to make private class member private

psychoticRabbit meagain at meagain.com
Tue Mar 13 11:19:59 UTC 2018


On Tuesday, 13 March 2018 at 08:29:42 UTC, Alex wrote:
> package myPackage;
>
> public class Main {
>
>     public static void main(String[] args)
>     {
>         System.out.println("Hello World!");
>         myClass c = new myClass();
>         c.myPrivateClassMember= "wtf";
>         System.out.println(c.myPrivateClassMember);
>     }
>
>     private static class myClass
>     {
>         private String myPrivateClassMember; // private does 
> not mean private anymore??
>     }
> }
> ´´´
> (may the forum forgive me :p )

But a class and its inner classes together, can be still be 
reasoned about locally.

With 'modules', the boundaries of what 'local' means, becomes 
more and more fuzzy, as the module gets longer and longer, and 
more and more complex.

In those circumstances, it becomes much harder to reason locally 
about the correctness of a class.

And a D module can go on..well...for ever.....

I would still prefer that classes within a module, at least have 
a capacity to specify access privileges to objects in the same 
module, rather than just trusting everything in that module, 
without exception.



More information about the Digitalmars-d-learn mailing list