[fpc-pascal] Traits Proposal
Ryan Joseph
genericptr at gmail.com
Wed Feb 17 15:46:14 CET 2021
> On Feb 17, 2021, at 6:17 AM, Sven Barth <pascaldragon at googlemail.com> wrote:
>
> 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.
Oh, so this is some extra code that runs every time you call a method of an interface? I understand interfaces and use them sometimes, but not all the internal workings in the compiler and how they're implemented.
> I have the feeling that you don't really know how interfaces work.
> 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.
>
> 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.
I'm talking about the decoupling of the interface and class and how that's a strange way to implement ARC. These wrapper functions and runtime lookups for casting are another side of it. I would hope someday we can implement ref counting in classes the same way as dynamic arrays and ansistrings, i.e. you just pass the reference and forget about it.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list