Hello!
Has anybody thought about multiple inheritance in object pascal? I am
now working on a client-server service that entirely uses ORM. I have
several patterns that repeat all over and some of them do not match into
the direct inheritance schema.
For now I solved multiple inheritance with include file templates (like
rtl/objpas/sysutils/finah.inc and fina.inc). But it would be much nicer
to have it built-in:
TBase = class(TObject)
private
FBaseField: Integer;
protected
procedure LoadFromNode(const aNode: TXMLNode); virtual;
public
property BaseField: Integer read FBaseField write FBaseField;
end;
TAddressExtension = class extension for TBase
private
FAddress: string;
protected
procedure LoadFromNode(const aNode: TXMLNode); override;
public
property Address: string read FAddress write FAddress;
end;
TTag = (black, gray, white, green, blue);
TTags = set of TTag;
TTagsExtension = class extension for TBase
private
FTags: TTags;
protected
procedure LoadFromNode(const aNode: TXMLNode); override;
public
property Tags: TTags read FTags write FTags;
end;
TCustomer = class(TBase, TAddressExtension, TTagsExtension)
protected
procedure LoadFromNode(const aNode: TXMLNode); override;
end;
TCustomer gets all fields and properties from TBase, TAddressExtension
and TTagsExtension. The LoadFromNode virtual method chain is:
TCustomer -> TTagsExtension -> TAddressExtension -> TBase.
Any thoughs on it? Is it sensible? How do you solve multiple inheritance?
+ If such a concept was in FPC, the LCL could get rid of the multiple
inheritance hacks in widgetset bindings :)
Ondrej
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel