digitalmars.D - Mixins and protection attributes
- Bruno Medeiros (24/24) Oct 24 2005 Some posts ago a code segment brought up an issue regarding Mixins and
- Sean Kelly (10/14) Oct 24 2005 There is a related bug (?) that private data in templates is not visible...
- Bruno Medeiros (13/36) Oct 25 2005 Your code is not valid. Perhaps you meant:
Some posts ago a code segment brought up an issue regarding Mixins and protection attributes within them. Namely, if protection attributes of a mixin member will be applied to the mixin own (declaration) scope, or to the enclosing scope where the mixin is instantiated. The code that illustrates this is: template Singleton(T) { private static T m_instance; public static this(){ m_instance = new T(); } public static T get(){ return m_instance; } private this(){} } class Foo { mixin Singleton!(Foo); // Error because Foo cannot access private Singleton.this() } Currently the protection attributes are applied to the mixin own scope, and it wasn't clear then whether this is intended or is a bug. So, which is it? -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural."
Oct 24 2005
In article <djj29j$14jf$1 digitaldaemon.com>, Bruno Medeiros says...Some posts ago a code segment brought up an issue regarding Mixins and protection attributes within them. Namely, if protection attributes of a mixin member will be applied to the mixin own (declaration) scope, or to the enclosing scope where the mixin is instantiated.There is a related bug (?) that private data in templates is not visible to the outside world. For example: class C() { private: void fn() {} } C!().fn(); // fails to compile This may be part of the current mixin problem. Sean
Oct 24 2005
Sean Kelly wrote:In article <djj29j$14jf$1 digitaldaemon.com>, Bruno Medeiros says...Your code is not valid. Perhaps you meant: templace C() { private: void fn() {} } C!().fn(); // fails to compile ? :p If so, yes it seems to be quite the same problem, but is it a bug or intended? (or unexpected?) -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural."Some posts ago a code segment brought up an issue regarding Mixins and protection attributes within them. Namely, if protection attributes of a mixin member will be applied to the mixin own (declaration) scope, or to the enclosing scope where the mixin is instantiated.There is a related bug (?) that private data in templates is not visible to the outside world. For example: class C() { private: void fn() {} } C!().fn(); // fails to compile This may be part of the current mixin problem. Sean
Oct 25 2005