Feature Enhancement: Protection attributes should work the same in all entities.

Kyle Furlong kylefurlong at gmail.com
Tue Mar 14 22:05:59 PST 2006


Bruno Medeiros wrote:
> Feature Enhancement: Protection attributes should work the same in all 
> entities, not just functions and variables.
> 
> Currently the D spec (http://www.digitalmars.com/d/attribute.html) 
> states implicitly that protection attributes apply only to members (of 
> classes and modules), with members being functions and variables. I 
> propose that the protection attributes work orthogonally for all 
> entities, meaning they should also apply to declarative entities like 
> classes and structs. (this is done in C# and Java)
> This would allow access control in ways such as these:
> 
> ----- moduleA
>   private class Foo {
>     public static void staticMethod() {}
>   }
> 
> ----- moduleB
>   // Accessing a class as part of another entity's access
>   moduleA.Foo.staticMethod(); // error: cannot access Foo
> 
>   // Accessing a class as a direct usage in a declaration
>   Foo foo; // error: cannot access Foo
> 
> 
> In the case of accessing a constructor (instantiating a class), access 
> it allowed if both the protection attribute of the class, and the class 
> constructor, allow it. (again, this is also how it works in Java and C#)
> 
> 
> Note: There is also currently a bug that makes protection attributes not 
> work with static members.
> 

This is obvious, any modern language needs this. Vote.



More information about the Digitalmars-d mailing list