[fpc-pascal] Traits Proposal

Michael Van Canneyt michael at freepascal.org
Sun Feb 14 13:30:25 CET 2021



On Sun, 14 Feb 2021, Sven Barth via fpc-pascal wrote:

>> So whether it be this, or just an improvement on the Interfaces we 
>> already have, I'd definitely personally be in favor of something that 
>> "works like Interfaces except minus the negative performance 
>> implications."
>
> There are no significant performance implications of interfaces. They're 
> essentially a virtual method call, something that one is doing all day 
> long with Object Pascal classes.

I think the "performance implications" is more referring to memory management.

Interfaces means an extra object per interface, so more objects on the 
heap with all the extra memory management that implies.

That is why I think that a 'trait' using an object/advanced record has it's 
advantage: There is only 1 continuous memory block for a class implementing
traits.

Michael.


More information about the fpc-pascal mailing list