Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2021-06

Generic procedure type declaration

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Henrique Gottardi Werlang

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. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20210604/80f5a917/attachment.htm>

Reply by email

Michael Van Canneyt
to Henrique Gottardi Werlang
Henrique Gottardi Werlang wrote 7 lines
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.

Reply by email

Sven Barth
to Michael Van Canneyt
Michael Van Canneyt wrote 27 lines
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

Reply by email