digitalmars.D.learn - Why has base class protection been deprecated?
- David Bryant (12/12) Apr 24 2012 With the dmd 2.059 I have started getting the error 'use of base class
- Don Clugston (5/17) Apr 24 2012 Because it doesn't make sense. All classes are derived from Object. That...
- David Bryant (3/5) Apr 24 2012 Does the same apply for interfaces? I'm specifically implementing an
- Don Clugston (2/9) Apr 24 2012 Right. Only classes are affected.
- David Bryant (4/14) Apr 24 2012 Ok...so I still don't understand why the original example shouldn't
- David Bryant (5/21) Apr 24 2012 To be clear: my subject line is misleading. I used that text because
- David Nadlinger (9/12) Apr 24 2012 Generally (and slightly inaccurately) speaking, D follows the
With the dmd 2.059 I have started getting the error 'use of base class protection is deprecated' when I try to implement an interface with private visibility, ie: interface Interface { } class Class : private Interface { } $ dmd test.d test.d(4): use of base class protection is deprecated This bothers me for two reasons: firstly it's not a base class, and secondly, it's a standard OO pattern of mine. What's up with this? Thanks, Dave
Apr 24 2012
On 24/04/12 14:22, David Bryant wrote:With the dmd 2.059 I have started getting the error 'use of base class protection is deprecated' when I try to implement an interface with private visibility, ie: interface Interface { } class Class : private Interface { } $ dmd test.d test.d(4): use of base class protection is deprecated This bothers me for two reasons: firstly it's not a base class, and secondly, it's a standard OO pattern of mine. What's up with this? Thanks, DaveBecause it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work. Previously, the compiler used to allow base class protection, but it ignored it.
Apr 24 2012
Because it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work.Does the same apply for interfaces? I'm specifically implementing an interface with non-public visibility. This shouldn't affect the visibility of the implicit Object base-class.
Apr 24 2012
On 24/04/12 15:29, David Bryant wrote:Right. Only classes are affected.Because it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work.Does the same apply for interfaces? I'm specifically implementing an interface with non-public visibility. This shouldn't affect the visibility of the implicit Object base-class.
Apr 24 2012
On 04/24/2012 11:07 PM, Don Clugston wrote:On 24/04/12 15:29, David Bryant wrote:Ok...so I still don't understand why the original example shouldn't compile. I'm not trying to change the visibility of the base class but rather the visibility of the interface.Right. Only classes are affected.Because it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work.Does the same apply for interfaces? I'm specifically implementing an interface with non-public visibility. This shouldn't affect the visibility of the implicit Object base-class.
Apr 24 2012
On 04/24/2012 11:47 PM, David Bryant wrote:On 04/24/2012 11:07 PM, Don Clugston wrote:To be clear: my subject line is misleading. I used that text because it's what came out of the compiler's mouth. I do understand your reasoning why you can't change the visibility of a base class, just not for an interface.On 24/04/12 15:29, David Bryant wrote:Ok...so I still don't understand why the original example shouldn't compile. I'm not trying to change the visibility of the base class but rather the visibility of the interface.Right. Only classes are affected.Because it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work.Does the same apply for interfaces? I'm specifically implementing an interface with non-public visibility. This shouldn't affect the visibility of the implicit Object base-class.
Apr 24 2012
On Tuesday, 24 April 2012 at 12:22:14 UTC, David Bryant wrote:This bothers me for two reasons: firstly it's not a base class, and secondly, it's a standard OO pattern of mine. What's up with this?Generally (and slightly inaccurately) speaking, D follows the Java model for inheritance rather than the C++ one, where base class protection attributes simply do not exist. Besides that, I'm not quite sure what privately inheriting an interface would buy you – there would be no implementation to inherit anyway (except for final interface methods, but I doubt a valid use case for this would be easy to find)? David
Apr 24 2012