[fpc-pascal] Traits Proposal

Sven Barth pascaldragon at googlemail.com
Tue Feb 16 19:48:27 CET 2021


Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Di., 16. Feb. 2021, 19:21:

> >
> > There we have:
> >
> > * slower creation of the class, because each implemented interface adds
> another VMT reference to the class which needs to be initialized.
>
> How bad is this? We need to make a test case we can profile. For example
> if you have a game that creates 1000 classes 60 frames per second. If
> adding interfaces to the classes hurts this process we may have a deal
> breaker.
>

If you need to create 1000 class instances each frame then you have a flaw
in your logic in my opinion.


> > * slow reference counting. Especially if it is thread safe and exception
> safe with the implicit exception block
>
> It's a whole other topic but FPC needs opt-in ARC at the language level
> for classes. Interfaces are not only slow but then you need to pass around
> a reference to the interface instead of the class you actually care about.
> It makes no sense to me whatsoever.
>

Interfaces are not slow because they are are interfaces! When you call a
interface method it has the same costs as a virtual method call! And the
cost for reference counting that interfaces have right now would be there
for ARC as well.

Regards,
Sven

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


More information about the fpc-pascal mailing list