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

Bruno Medeiros daiphoenixNO at SPAMlycos.com
Tue Mar 14 12:14:24 PST 2006


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.

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list