Disclaimer: This is not intented as a flame war lighter, but a feature
request... ;-)
I've been working on another OO designed system, and ran across a situation
where multiple inheritance (as I understand it) would come in REALLY handy.
In the traditional OO framework, there is the problem domain class and the
persistance class. When persisting (if there is such a word), the PD class
must either expose all of its' variables to be persisted, or provide a
method to write its' variables out to the persistance class. If the
persistance class could inherit from both the base persistance class AND the
specific PD class, the resulting object would have "knowledge" of the PD
internals as well as descend from the persistance object.
In short, multiple inheritance would eliminate some unnecessary code from
either/both of the (PD/persistance) classes.
I would like to be able to do the following...
type
class TFoo(TObject)
public
Name: string;
private
FFooData: string;
end;
class TBar(TObject)
public
Name: string;
private
FBarData: string;
end;
class TFooBar(TFoo, TBar)
public
// To show which class takes prescedence
// for name duplicates, a keyword (derived)
// or the like would need to be introduced.
// The compiler could default to the first
// class listed in the declaration, then the
// programmer would need to use the
// derived keyword only to override the
// default.
Name: string; derived TBar;
private
procedure SaveData;
end;
{---Later---}
procedure TFooBar.SaveData;
begin
SaveSomeData(FFooData);
SaveSomeData(FBarData);
SaveSomeData(Name); // Would save TBar.Name
end;
One could extend the multiple inheritance paradigm to inherit from many
classes at once...
class TFooBarBob(TFoo, TBar, TBob)
end;
The properties and methods from each of the derived classes would be
available to a descendent of TFooBarBob, and any name conflicts (for
properties) would be handled by classes listed first in order or the
"derived" directive.
Comments?
Eric Hill