[fpc-devel] Templates / Generics Syntax
Mattias Gaertner
nc-gaertnma at netcologne.de
Thu Nov 3 19:14:58 CET 2005
Here is a proposal of the syntax:
type
TGenericClass<T,F> = class
public
procedure Add(Item: T; Flag: F);
end;
procedure TGenericClass.Add(Item: T; Flag: F);
// Note: No redundant <T,F> after TGenericClass.
begin
end;
I think, the parameters should be at the identifier name, not in the class
block, because that's the way you use them:
type TListOfComponent = TGenericList<TComponent>;
Analog:
type TGenericListClass<T> = class of TGenericList<T>;
type PGenericRecord<T> = ^TGenericRecord<T>;
procedure GenericProc<T>(Param: T);
begin
end;
Mattias
More information about the fpc-devel
mailing list