[fpc-pascal] Generics vs templates
Ryan Joseph
ryan at thealchemistguild.com
Wed Jan 10 04:39:29 CET 2018
> On Jan 10, 2018, at 6:37 AM, Graeme Geldenhuys <mailinglists at geldenhuys.co.uk> wrote:
>
> When using the Generics.Collections unit of Delphi I can define a list class that can hold Integer data types, by doing the following:
>
> var
> IntList: TList<Integer>;
> begin
> IntList := TList<Integer>.Create;
> IntList.Add(12345);
I presume then TList<> and TList class are not implemented the same then because I still don’t know how the generic itself affects runtime performance.
Btw this looks like C# code because C# explicitly does not specialize at compile time but rather runtime so every instance will be using TList<Integer>. Does Delphi do this also? I think FPC requires you MUST specialize at compile time so simply using TList<Integer> won’t compile.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list