Search code examples
delphifreepascallazarus

How to translate `reference to procedure` from Delphi to Lazarus?


Disclaim: I am asking to "Lazarus" because I don't really care about mode Delphi or mode ObjFPC...

I am translating some code from "Delphi 11" to Lazarus and found those:

TProc = reference to procedure(const AControl: TControl);
....
proc := MyProcedure;

This seems to be some managed reference to method for event callback, if I am correct.

How would I make something equivalent under Lazarus ?


Solution

  • You can use FPC from the main branch, which has this feature since May of last year. However, it will only be in the next major version release, which is not on the horizon, as far as I know.

    Official announcement of the feature:

    Feature announcement: Function References and Anonymous Functions