digitalmars.D - Implementing multiple inheritance in D
- kenji hara (11/11) May 09 2011 I have tried to implement multiple inheritance in D.
- Andrei Alexandrescu (10/21) May 09 2011 This is very interesting. I don't understand the example though (some is...
- kenji hara (13/15) May 10 2011 I posted 'Issue 5973 - alias this is not considered with superclass
- Jacob Carlborg (4/15) May 09 2011 Why not emulate it with interfaces and template mixins?
- kenji hara (3/4) May 10 2011 Interfaces? I don't understand what you mean.
- Jacob Carlborg (16/20) May 10 2011 interface Super {
I have tried to implement multiple inheritance in D. My first idea is binary inheritance tree with using alias this, but current dmd doesn't look alias this on superclasses. So I have tried to fix this behavior. -> https://github.com/9rnsr/dmd/tree/MultiInheritPatch Result: -> http://ideone.com/iD4JE Some issues: - Calling constructors of superclasses syntax. - Object layout (share __monitor object? reduce overhead?) Do you think?
May 09 2011
On 5/9/11 12:43 PM, kenji hara wrote:I have tried to implement multiple inheritance in D. My first idea is binary inheritance tree with using alias this, but current dmd doesn't look alias this on superclasses. So I have tried to fix this behavior. -> https://github.com/9rnsr/dmd/tree/MultiInheritPatch Result: -> http://ideone.com/iD4JE Some issues: - Calling constructors of superclasses syntax. - Object layout (share __monitor object? reduce overhead?) Do you think?This is very interesting. I don't understand the example though (some is commented out, some is in, and I'm unclear on what didn't use to work and what works). Also I can't find the important commits in your branch, so it may be best to organize those as one pull request for the dmd mainline. Could you please provide more detail on what you fixed and what the resulting context is? Thanks, Andrei
May 09 2011
Thanks for your comment.Could you please provide more detail on what you fixed and what the resulting context is?I posted 'Issue 5973 - alias this is not considered with superclass lookup' for dmd issue. http://d.puremagic.com/issues/show_bug.cgi?id=5973 The issue is that dmd does not consider alias this in super classes on member lookup. More clean code: https://github.com/9rnsr/scrap/blob/master/multiInherit.d New feature: - Support class that have explicit constructor. See X.this code with -version=ExplicitCtor. May not support: - Diamond inheritance Kenji Hara
May 10 2011
On 2011-05-09 19:43, kenji hara wrote:I have tried to implement multiple inheritance in D. My first idea is binary inheritance tree with using alias this, but current dmd doesn't look alias this on superclasses. So I have tried to fix this behavior. -> https://github.com/9rnsr/dmd/tree/MultiInheritPatch Result: -> http://ideone.com/iD4JE Some issues: - Calling constructors of superclasses syntax. - Object layout (share __monitor object? reduce overhead?) Do you think?Why not emulate it with interfaces and template mixins? -- /Jacob Carlborg
May 09 2011
Why not emulate it with interfaces and template mixins?Interfaces? I don't understand what you mean. So please give me a example code. Kenji Hara
May 10 2011
On 2011-05-10 10:14, kenji hara wrote:interface Super { void foo (); } template SuperImpl { void foo () { /* do something */ } } class Sub : Super { mixin SuperImpl; void bar () { /* do something else */ } } This might not be the best solution, it won't work with existing class hierarchies. I've actually tried this now and it won't work, you cannot override the methods coming from the mixin. -- /Jacob CarlborgWhy not emulate it with interfaces and template mixins?Interfaces? I don't understand what you mean. So please give me a example code. Kenji Hara
May 10 2011