[fpc-pascal] Procedural generics question
noreply at z505.com
noreply at z505.com
Fri Sep 4 03:58:49 CEST 2020
On 2020-08-26 05:44, Nico Neumann via fpc-pascal wrote:
> The TypeInfo function checks the code during run-time thus the
> generated code is 'bloated'. Better use the compiler intrinsic
> GetTypeKind.
>
> {$mode objfpc}
>
> uses
> typinfo;
>
> generic procedure Add<T>;
> begin
> if GetTypeKind(T) = tkInteger then WriteLn('an integer');
> if GetTypeKind(T) = tkString then WriteLn('a string');
> end;
>
That's great but if the type is something like a TRec (custom record) or
a class, it won't be possible to check the types AFAICT because those
are special built in type kind values for common basic types?
More information about the fpc-pascal
mailing list