[fpc-pascal] Caller agnostic procedure variables

Sven Barth pascaldragon at googlemail.com
Tue Feb 15 17:09:11 CET 2022


Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Di., 15. Feb. 2022, 15:02:

>
>
> > On Feb 15, 2022, at 8:32 PM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > A function reference is simply an interface of which the Invoke method
> can be called on the instance instead of manually doing "Foo.Invoke".
> >
> > The real "magic" is when the compiler generates the *implementation* of
> said interface. So in the end what can be assigned to a function reference
> depends on the compiler being able to generate suitable implementations.
>
> So when you assign a global function to a function reference it has to
> generate a new function body? I guess that makes sense on how it can
> "capture" these different types of functions.
>

For a global function the compiler has to generate a wrapper that gets rid
of the Self parameter of the interface.

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20220215/c5cbb9fd/attachment-0001.htm>


More information about the fpc-pascal mailing list