Thread overview | |||||
---|---|---|---|---|---|
|
March 14, 2006 Feature Enhancement: Protection attributes should work the same in all entities. | ||||
---|---|---|---|---|
| ||||
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 |
March 15, 2006 Re: Feature Enhancement: Protection attributes should work the same in all entities. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros | "Bruno Medeiros" <daiphoenixNO@SPAMlycos.com> wrote in message news:dv7816$q0b$3@digitaldaemon.com... > 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) Vote! |
March 15, 2006 Re: Feature Enhancement: Protection attributes should work the same in all entities. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros | 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.
|
Copyright © 1999-2021 by the D Language Foundation