D - changing protected variable
- Yan (19/19) Feb 09 2004 As I suppose "protected" variable could not be changed outside the class...
- Roel Mathys (9/34) Feb 09 2004 hmm,
- Yan (4/38) Feb 09 2004 Specification describes access rules in different way:
- Roel Mathys (4/58) Feb 09 2004 yep,
- Roel Mathys (19/73) Feb 09 2004 although, the text beneath is stripped from the "Attributes" page:
- Yan (3/21) Feb 09 2004 Yes, from this page. In my view it clearly means that i can not
- Roel Mathys (13/45) Feb 09 2004 you are absolutely right,
- Yan (29/74) Feb 10 2004 My uderstanding of what describes specification is like that:
- Hauke Duden (3/9) Feb 10 2004 Agreed!
- Manfred Nowak (9/12) Feb 10 2004 But how is the logical structure related to the physical layout of a
- Yan (11/23) Feb 11 2004 IMHO logical structure should not be related to the physical layout.
- Manfred Nowak (7/11) Feb 11 2004 [...]
- Manfred Nowak (5/8) Feb 10 2004 Look at the friends section:
As I suppose "protected" variable could not be changed outside the class. This program prints x=2 y=1 hmm... import std.c.stdio; int main(char[][] args) { Vector v =new Vector(); v.x = 2; printf("x=%d y=%d ",v.x,v.y); return 0; } class Vector { protected int x; protected int y; this() { // create vector x = 1; y = 1; } }
Feb 09 2004
Yan wrote:As I suppose "protected" variable could not be changed outside the class. This program prints x=2 y=1 hmm... import std.c.stdio; int main(char[][] args) { Vector v =new Vector(); v.x = 2; printf("x=%d y=%d ",v.x,v.y); return 0; } class Vector { protected int x; protected int y; this() { // create vector x = 1; y = 1; } }hmm, I think the access rules play outside the module wherein a variable is declared/defined. This means inside a module (one file) the access restrictions are not enforced. bye, roel btw: I did not verify this little story
Feb 09 2004
In article <c08cli$2op9$1 digitaldaemon.com>, Roel Mathys says...Yan wrote:Specification describes access rules in different way: "Protected means that only members of the enclosing class or any classes derived from that class can access the member."As I suppose "protected" variable could not be changed outside the class. This program prints x=2 y=1 hmm... import std.c.stdio; int main(char[][] args) { Vector v =new Vector(); v.x = 2; printf("x=%d y=%d ",v.x,v.y); return 0; } class Vector { protected int x; protected int y; this() { // create vector x = 1; y = 1; } }hmm, I think the access rules play outside the module wherein a variable is declared/defined. This means inside a module (one file) the access restrictions are not enforced.bye, roel btw: I did not verify this little story
Feb 09 2004
Yan wrote:In article <c08cli$2op9$1 digitaldaemon.com>, Roel Mathys says...yep, sorry, roelYan wrote:Specification describes access rules in different way: "Protected means that only members of the enclosing class or any classes derived from that class can access the member."As I suppose "protected" variable could not be changed outside the class. This program prints x=2 y=1 hmm... import std.c.stdio; int main(char[][] args) { Vector v =new Vector(); v.x = 2; printf("x=%d y=%d ",v.x,v.y); return 0; } class Vector { protected int x; protected int y; this() { // create vector x = 1; y = 1; } }hmm, I think the access rules play outside the module wherein a variable is declared/defined. This means inside a module (one file) the access restrictions are not enforced.bye, roel btw: I did not verify this little story
Feb 09 2004
Yan wrote:In article <c08cli$2op9$1 digitaldaemon.com>, Roel Mathys says...although, the text beneath is stripped from the "Attributes" page: --> Protection Attribute Protection is an attribute that is one of private, protected, public or export. Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class. Private members cannot be overridden. Private module members are equivalent to static declarations in C programs. Protected means that only members of the enclosing class or any classes derived from that class can access the member. Protected module members are illegal. Public means that any code within the executable can access the member. Export means that any code outside the executable can access the member. Export is analogous to exporting definitions from a DLL. <-- bye, roelYan wrote:Specification describes access rules in different way: "Protected means that only members of the enclosing class or any classes derived from that class can access the member."As I suppose "protected" variable could not be changed outside the class. This program prints x=2 y=1 hmm... import std.c.stdio; int main(char[][] args) { Vector v =new Vector(); v.x = 2; printf("x=%d y=%d ",v.x,v.y); return 0; } class Vector { protected int x; protected int y; this() { // create vector x = 1; y = 1; } }hmm, I think the access rules play outside the module wherein a variable is declared/defined. This means inside a module (one file) the access restrictions are not enforced.bye, roel btw: I did not verify this little story
Feb 09 2004
Yes, from this page. In my view it clearly means that i can not assign "protected" variable outside the class. Am I right? Yanalthough, the text beneath is stripped from the "Attributes" page: --> Protection Attribute Protection is an attribute that is one of private, protected, public or export. Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class. Private members cannot be overridden. Private module members are equivalent to static declarations in C programs. Protected means that only members of the enclosing class or any classes derived from that class can access the member. Protected module members are illegal. Public means that any code within the executable can access the member. Export means that any code outside the executable can access the member. Export is analogous to exporting definitions from a DLL. <-- bye, roel
Feb 09 2004
Yan wrote:Yes, from this page. In my view it clearly means that i can not assign "protected" variable outside the class. Am I right? Yanyou are absolutely right, but private members would be accessible from the module level. my summary would be: - public: accessible everywhere, including module level - protected: accessible in downward class hierarchy => but derived classes can be in other modules - private: from module level, including other (derived) classes in this module (and "finalizes" a specific class member when used) => one can't compare private and protected, they are two different concepts, I think this one could be tricky for C++ users bye, roelalthough, the text beneath is stripped from the "Attributes" page: --> Protection Attribute Protection is an attribute that is one of private, protected, public or export. Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class. Private members cannot be overridden. Private module members are equivalent to static declarations in C programs. Protected means that only members of the enclosing class or any classes derived from that class can access the member. Protected module members are illegal. Public means that any code within the executable can access the member. Export means that any code outside the executable can access the member. Export is analogous to exporting definitions from a DLL. <-- bye, roel
Feb 09 2004
In article <c08qin$10oi$1 digitaldaemon.com>, Roel Mathys says...Yan wrote:My uderstanding of what describes specification is like that: (Table1) Out of module Module Class Subclass public + + + + private - - + - protected - - + +Yes, from this page. In my view it clearly means that i can not assign "protected" variable outside the class. Am I right? Yanalthough, the text beneath is stripped from the "Attributes" page: --> Protection Attribute Protection is an attribute that is one of private, protected, public or export. Private means that only members of the enclosing class can access the member, or members and functions in the same module as the enclosing class. Private members cannot be overridden. Private module members are equivalent to static declarations in C programs. Protected means that only members of the enclosing class or any classes derived from that class can access the member. Protected module members are illegal. Public means that any code within the executable can access the member. Export means that any code outside the executable can access the member. Export is analogous to exporting definitions from a DLL. <-- bye, roelyou are absolutely right, but private members would be accessible from the module level.That means: (Table2) Out of module Module Class Subclass public + + + + private - - + - protected - __+__ + +my summary would be: - public: accessible everywhere, including module level - protected: accessible in downward class hierarchy => but derived classes can be in other modules - private: from module level, including other (derived) classes in this module (and "finalizes" a specific class member when used)That is means: (Table3) Out of module Module Class Subclass public + + + + private - + + +(only in Module) protected - - + +(also in other Modules) I think that LOGICAL structure of the program is more important, rather than PHISICAL distribution of classes in source files. So, imho Module should not be or equial to file. Many classes in different files could represent ONE module. Accessibility should not be connected with file structure of the project, but with logical structure. That is why I like Table1. regards, Yan=> one can't compare private and protected, they are two different concepts, I think this one could be tricky for C++ users bye, roel
Feb 10 2004
Yan wrote:I think that LOGICAL structure of the program is more important, rather than PHISICAL distribution of classes in source files. So, imho Module should not be or equial to file. Many classes in different files could represent ONE module. Accessibility should not be connected with file structure of the project, but with logical structure.Agreed! Hauke
Feb 10 2004
Hauke Duden wrote:Yan wrote:[...]But how is the logical structure related to the physical layout of a project? From the friends section of the docs: | It makes sense that tightly related classes should be in the same module Should this be exended to the already available meaning of `package', i.e. modules that reside in the same directory? So long.but with logical structure.Agreed!
Feb 10 2004
In article <c0bmap$2lsi$2 digitaldaemon.com>, Manfred Nowak says...Hauke Duden wrote:IMHO logical structure should not be related to the physical layout. "project" is a substance controlled by IDE (for example) but not by compiler or linker.. Classes of the same module could be placed in several files (even on different computers..) Relation of logical structure and physical layout should be determined by programmer when he call compiler,linker or make.. May be i'm wrong but i see this concept as more universal. regards YanYan wrote:[...]But how is the logical structure related to the physical layout of a project?but with logical structure.Agreed!From the friends section of the docs: | It makes sense that tightly related classes should be in the same module Should this be exended to the already available meaning of `package', i.e. modules that reside in the same directory? So long.
Feb 11 2004
Yan wrote: [...]"project" is a substance controlled by IDE (for example) but not by compiler[...]Classes of the same module could be placed in several files (even on different computers..)What are the differences between your thinking in modules and projekts? And why s it not neccassary, that the used formal language is aware of that? So long.
Feb 11 2004
Yan wrote: [...]Specification describes access rules in different way: "Protected means that only members of the enclosing class or any classes derived from that class can access the member."Look at the friends section: | In D, friend access is implicit in being a member of the same module. So long.
Feb 10 2004