[fpc-pascal] Usage of Generics in FPC

Florian Klaempfl florian at freepascal.org
Thu Feb 12 12:46:44 CET 2009


Graeme Geldenhuys schrieb:
> Why can't I do the following:
> 
> procedure WriteSquares(AMax: Integer);
> var
>   List: specialize TFPGList<integer>;
> begin
>   List := TFPGList<integer>.Create;
> 
> 
> ...instead I have to ALWAYS declare a type first....
> 
> 
> type
>   TIntList = specialize TFPGList<Integer>;
> 
> procedure WriteSquares(AMax: Integer);
> var
>   List: TIntList;
> begin
>   List := TIntList.Create;

You can't do

longintpointer:=^longint(p);

in pascal either but you need

type
plongint = ^longint;

...
longintpointer:=plongint(p);

so it's imo logical that generics must be specialized explicitly before
they can be used. Same applies e.g. for parameter types too.



More information about the fpc-pascal mailing list