<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Ryan Joseph via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Di., 15. Feb. 2022, 15:02:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Feb 15, 2022, at 8:32 PM, Sven Barth via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> wrote:<br>
> <br>
> A function reference is simply an interface of which the Invoke method can be called on the instance instead of manually doing "Foo.Invoke".<br>
> <br>
> 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. <br>
<br>
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.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">For a global function the compiler has to generate a wrapper that gets rid of the Self parameter of the interface. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>