[fpc-devel] Templates / Generics Syntax
marc.weustink at cuperus.nl
Fri Nov 4 14:07:50 CET 2005
Ales Katona wrote:
> Micha Nelissen wrote:
>> Marc Weustink wrote:
>>> what woud be the problem with
>>> TMySpecificClass = TGenericClass(TObject, Integer);
>> TGenericCollection = generic(T: TCollectionItem) class(TComponent)
>> ...implement TCollection and use T
>> TCollection = TGenericCollection of (TCollectionItem);
>> TFieldDefs = TGenericCollection of (TFieldDef);
>> TGenericList = generic(T: PtrInt) class(TObject)
>> ...implement TList and use PtrInt size for code generation
>> TList = TGenericList of (Pointer);
>> 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.
> Are the () required? Why not TSomeList = TGenericList of Pointer; ?
You can have more types
TList = TGenericList of (Pointer, Pointer);
More information about the fpc-devel