Micha Nelissen wrote:
<code>
type
TGenericCollection = generic(T: TCollectionItem) class(TComponent)
...implement TCollection and use T
end;
TCollection = TGenericCollection of (TCollectionItem);
TFieldDefs = TGenericCollection of (TFieldDef);
</code>
So generic procs could look like:
<code>
function generic(T: TTreeItem) MyFunc(A: T): T;
begin
// do something with the tree item
end;
</code>
My restrictions won't allow implementing generic Max and Min, I guess.
That really needs macro-alike stuff (for the compiler implementation).
The syntax could look like:
<code>
function generic(T) Max(A, B: T): T;
begin
if A < B then
Result := B
else
Result := A;
end;
</code>
Micha
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel