[fpc-devel] Templates / Generics Syntax

Ales Katona almindor at gmail.com
Fri Nov 4 14:05:48 CET 2005


Micha Nelissen wrote:

> 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
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>
Are the () required? Why not TSomeList = TGenericList of Pointer; ?

Ales



More information about the fpc-devel mailing list