[fpc-pascal] Creating capturers

Hairy Pixels genericptr at gmail.com
Fri Nov 3 12:37:31 CET 2023



> On Nov 3, 2023, at 2:08 PM, Sven Barth <pascaldragon at googlemail.com> wrote:
> 
> By default the purpose of anonymous functions assigned to function references *is* that they can escape their scope. This will not change, because they were after all introduced for Delphi-compatibility and there won't be any designations that the value can't escape. If the compiler can't figure it out by its own (see above) then tough luck; use a feature better suited for that. 
> 

Ok I misinterpreted what you previously said then.

I think Swift does this because they only have a single function pointer type which serves all purposes while FPC has 4 distinct types.

IMO FPC needs this also since it's not possible for libraries to know which kind of function the caller may provide. Behind the scenes the different types are required (global, nested, method, reference) but there should be a way to unify these into single type. How to store the capturer and manage its memory would be an open question though.


Regards,
Ryan Joseph



More information about the fpc-pascal mailing list