[fpc-devel] Using case statement instead of VTable
genericptr at gmail.com
Tue Apr 11 10:50:11 CEST 2023
> On Apr 11, 2023, at 2:58 PM, Marco van de Voort via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
> But the core problem is that you don't have an overview of all other descendants in the compiler. Those can be fragmented over multiple units, and then you touch the problem that whole program optimization like de-virtualization tries to solve.
I didn’t get this at first but I see what you mean. The call site would only have access the descendants it knew about that point during compilation. So the case may not have a full set of descendants to work from.
I used to write code like this and there was always a way to make things work so maybe in practice it’s not as bad as it sounds but the VTable is clearly a more general purpose solution.
More information about the fpc-devel