On Thu, 3 Sep 2020, Lars via fpc-pascal wrote:
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 procedur
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;
begin
if GetTypeKind(T) = tkInteger then
> 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
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
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
> 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
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
Hi,
that is generating rather odd code (r40721)
project1.lpr:9 begin
00401090 55 push %rbp
00401091 4889e5 mov %rsp,%rbp
00401094 488d6424f0 lea -0x10(%rsp),%rsp
00401099 48895df
> I remember something like this in RTTI though but can't find it in your
docs yet for generics.
{$mode objfpc}
uses
typinfo;
generic procedure Add;
begin
if TypeInfo(T) = TypeInfo(Integer) then WriteLn('an integer');
if TypeInfo(T) = TypeInfo(String) then WriteLn('a string');
end;
begi
Inside a generic procedure (no objects used just a procedure) is there a
way to check which type the code is being used for such as:
generic procedure Add();
begin
if type = integer then...
if type = string then...
begin
// specialized code for that type only
end
end;
I remember so
10 matches
Mail list logo