[Pas2js] Generic procedure type declaration

Sven Barth pascaldragon at googlemail.com
Fri Jun 4 21:04:13 CEST 2021


Am 04.06.2021 um 14:14 schrieb Michael Van Canneyt:
>
>
> On Fri, 4 Jun 2021, Henrique Gottardi Werlang wrote:
>
>> I tried to find in the FPC documentation how to declare a generic 
>> procedure type, but i didn't find out.
>>
>> What I'm trying to declare is something like this:
>>
>> TMyProcType<T> = procedure(Param: T);
>>
>> This kind of statement is made in Delphi, but I didn't figure out how 
>> to do it in FPC.
>
> Works as-is:
>
> home:~> fpc tgm.pp
> home:~> pas2js tgm.pp
> Info: 1156 lines in 2 files compiled, 0.0 secs
> home:~> cat tgm.pp
> {$mode delphi}
>
> Type
>   TMyProcType<T> = procedure(Param: T);
>
> begin
> end.

Note: in mode ObjFPC (which is the default of Pas2JS) the declaration 
would be

type
   generic TMyProcType<T> = procedure(Param:T);

Just for the sake of completeness. ;)

Regards,
Sven


More information about the Pas2js mailing list