[fpc-devel] Templates / Generics Syntax
Micha Nelissen
micha at neli.hopto.org
Fri Nov 4 14:00:53 CET 2005
Marc Weustink wrote:
> BTW,
> what woud be the problem with
>
> type
> TMySpecificClass = TGenericClass(TObject, Integer);
Or:
<code>
type
TGenericCollection = generic(T: TCollectionItem) class(TComponent)
...implement TCollection and use T
end;
TCollection = TGenericCollection of (TCollectionItem);
TFieldDefs = TGenericCollection of (TFieldDef);
</code>
And:
<code>
type
TGenericList = generic(T: PtrInt) class(TObject)
...implement TList and use PtrInt size for code generation
end;
TList = TGenericList of (Pointer);
</code>
Combining some of the wiki ideas, and has no "evil" <> characters :-).
Probably TFieldDefs adds functionality to TCollection, but it was first
example I came up with.
Implementation of TGenericCollection can be compiled as if (T:
TCollectionItem) were used.
Would this solve the circular dependency ? It seems so to me, because
one knows at least as much as in current implementation of these
classes, but I'm no compiler engineer.
Micha
More information about the fpc-devel
mailing list