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;
begin
if GetTypeKind(T) = tkInteger then WriteLn('an integer');
if GetTypeKind(T) = tkString t
> On Aug 26, 2020, at 5:44 PM, Nico Neumann via fpc-pascal
> wrote:
>
> generic procedure Add;
> begin
> if GetTypeKind(T) = tkInteger then WriteLn('an integer');
> if GetTypeKind(T) = tkString then WriteLn('a string');
> end;
Question for the compiler team why doesn't the "is" operat
Am 26.08.2020 um 14:59 schrieb Ryan Joseph via fpc-pascal:
On Aug 26, 2020, at 5:44 PM, Nico Neumann via fpc-pascal
wrote:
generic procedure Add;
begin
if GetTypeKind(T) = tkInteger then WriteLn('an integer');
if GetTypeKind(T) = tkString then WriteLn('a string');
end;
Question fo
Am 25.08.2020 um 23:47 schrieb Benito van der Zander via fpc-pascal:
Hi,
that is generating rather odd code (r40721)
project1.lpr:9 begin
00401090 55 push %rbp
00401091 4889e5 mov %rsp,%rbp
00401094
> On Aug 27, 2020, at 3:49 AM, Sven Barth wrote:
>
>> if T is integer then
>> ;
>>
>> and get something which is well optimized.
> Because there was simply no need for this.
Since the introduction of generics this would be a nice extension to add for
the is operator.
Regards,
Ryan