On Tuesday, 13 March 2018 at 07:39:04 UTC, psychoticRabbit wrote:

I don't have any objection to the idea that a module can have privileged access to members of classes within that model. It sounds sensible enough, if the module is a level of encapsulation also.

My arguments is that, this was implemented in D, at the cost of removing the capacity for a class in the same module to protect it's own members (within the module). That's what I don't like about it.

My other objection, as stated, is that D uses the same syntax as C++/C#/Java, but the semantics of that same syntax are completely different. I also don't like that.

If you are missing more fine grained encapsulation control: take a look at
https://wiki.dlang.org/Access_specifiers_and_visibility#package

If you are in debt, that encapsulation at module level is more superior with respect to encapsulation and expressiveness in comparison to class level, look at Fortran and Java 9.

And last but not least:

´´´
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 )

Reply via email to