Inheriting constructors
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Sat Jun 2 03:43:53 PDT 2007
Chris Nicholson-Sauls wrote:
> Jari-Matti Mäkelä wrote:
>> Sean Kelly wrote:
>>
>> A bit off-topic (sorry), but you're using protection modifiers here:
>>
>>> class PrintOnDestruct( T ) :
>>> public T
>>
>> and here
>>
>>> class Placed( T ) :
>>> public T
>>
>> Are you also suggesting that D should support those like C++ does?
>
> Actually, they are already allowed. Check the grammar at the online docs:
> http://digitalmars.com/d/class.html
>
> You will see that it allows both 'SuperClass' and 'InterfaceClass' to be
> preceded by a
> 'Protection'. That said, I don't know that I've ever seen anyone actually
> bother using this in D, nor am I sure of its utility.
They have been there and I have asked this previously, yes. However, the
compiler does not use them (yet?).
I think they cause problems:
// module 1
interface foo { void method(); }
class base : foo { void method() {} }
class moo: private base {}
// module 2
void main() {
foo m = new moo();
m.method(); // bang, runtime error
}
Maybe this is something C++ programmers like, but in java/c# world there are
others ways to do this. And I think the inheritance model in D is closer to
Java than C++ so that's why it feels weird to me.
>
> -- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list