<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 Mi., 17. Feb. 2021, 02:21:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Feb 16, 2021, at 3:35 PM, Benito van der Zander via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> wrote:<br>
> <br>
> But it is not calling the method, it is calling the wrapper function<br>
<br>
what you say wrapper function do you mean the ref counting functions when you pass around the interface?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">No. With wrapper function he means the thunks that are responsible for adjusting the instance pointer of the interface to the instance pointer of the class before jumping to the method of the class. </div><div dir="auto"><br></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">I guess for ref counting you're supposed to cast the class to the interface (which is an expensive runtime lookup) and then pass that thing around? That seems like a crazy way to get ref counting plus you need to cast the interface back to the class if you want to call other methods? I still don't get this pattern. ARC should be handled by the compiler and be on the class itself, not some additional object you need to create and then store. <br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">I have the feeling that you don't really know how interfaces work.</div><div dir="auto">ARC would have the exact same penalty as the reference counting of interfaces, because that is essentially what the compiler would use: call some function that increases/decreases the reference count of the instance. That is *exactly* what is done for interfaces. </div><div dir="auto"><br></div><div dir="auto">Also the interface is not created. It's part of the class instance. You simply have a pointer sized value that points to that. In the ideal situation of *only* working with the interface you can simply forget the class instance, cause the class will be freed once the reference count reached 0. Thus there will be *no* additional storage involved.</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>