Single "alias this"
Deokjae Lee
asitdepends at gmail.com
Sun Jul 25 01:55:06 PDT 2010
Is there any particular reason to disallow multiple "alias this" ?
<code>
import std.stdio;
class A {
}
class B {
}
class C {
private A a;
alias a this;
private B b;
alias b this;//compile-time error
this() {
a = new A();
b = new B();
}
}
void main() {
C c = new C();
}
</code>
I can implement "multiple" interfaces and extend "single" base class in
Java like this:
<code>
class C extends BaseClass implements Interface1, Interface2, ...
</code>
But I can't do it using D. Code like the following does not be compiled.
<code>
class C : BaseClass, Interface1, Interface2, ...
</code>
Is there any particular reason? What's the difference between Java's
approach and single "alias this"?
More information about the Digitalmars-d-learn
mailing list