What is it with all the offensiveness? I did not know there was a paradigm of the diamond of death until I did google it. When I googled it I replied that I found the answer already. And I posted code that showed there is no diamond of death in pascal with my solution. Wan't me to start a NewNewPascal? This is how the thread started in the first place. This is only bashing and no discussion. I know now you're against multiple inheritance, I just don't know why because you didn't explain what is wrong with my code (Which isn't even real multi inheritance). The code works already (with function headers and unit stuff added). It is either a bug in the compiler or a broken feature (because of the problems with the destructor and code completion (not in the compiler, I know)) depending on how you see it. It is not the only way to fake multi inheritance by the way. You can also do it with macros and includes but it is kind of ugly.
So can't we just be friendly? It would help the Free Pascal community a lot more than any new feature.
But maybe I got you all wrong and your post wasn't meant as an offense. In this case I didn't get it. Otherwise I'm out of this "discussion" until we are back to normal.
Fist of all, interfaces have exactly the same "diamond of death" problem, as multiple inheritance. They have lesser problems, cuz they have lesser features - no fields, no constructors, etc. But remember this? Method name ambiguity, yeah.
IInterface1 = interface
procedure MyMethod;
end;
IInterface2 = interface
procedure MyMethod;
end;
TMyClass = class(TInterfacedObject, IInterface1, IInterface2)
procedure MyMethod1;
procedure MyMethod2;
//Diamond of death disambiguation here
procedure IInterface1.MyMethod = MyMethod1;
procedure IInterface2.MyMethod = MyMethod2;
end;
I.e. "diamond of death" - is possible situation only, so it should be dealt with somehow on compiler level. It's programmer himself, who create it. And it's up to programmer to avoid it. I.e. if you don't know, how to properly use some feature - don't just mindlessly use it. Any feature should be used as a tool to solve some problems and one should clearly understand, how it works, not just use it, cuz it exists.
Second. Sorry, that I haven't noticed your code. That's, what I need. Does it really work now? It can be solution of my problems, cuz I was seeing it as some sort of "subclass" feature. Something like this:
TAbstractClass = class
procedure SomeMethod;virtual;abstract;
end;
TSubclass = subclass(TAbstractClass)
procedure SomeMethod;override;
end;
//TAbstractClass somewhere in inheritance stucture
TSomeAncestor = class(TAbstractClass);
//Actual implementation
TMyClass = class(TSomeAncentor);
//Now we subclass it
MyObject := TMyClass.Create;
Subclass(MyObject, TSubclass);
//Or may be
TSubclass.Subclass(MyObject);
//Or another variant
NewObject := TSubclass.Subclass(MyObject);
And your code does exactly the same, but statically.