> On Apr 11, 2023, at 2:58 PM, Marco van de Voort via fpc-devel > <fpc-devel@lists.freepascal.org> wrote: > >> case animal.type of >> TDog: TDog(animal).DoSomething; >> TCat: TCat(animal).DoSomething; >> TMouse: TMouse(animal).DoSomething; >> end; > > This doesn't happen. There is no class that is TDog,Cat and mouse. Usually a > VMT governs the relation between parent and child, i.e. TDog and TAnimal. > The TDog nor the TAnimal implementation has no knowledge of the other mammals.
Address this part first since maybe my example was poor. I was trying to model how polymorphism is done in pure procedural code. I used to write code like this so I kind of remember. The idea is that there is a record with an enum which is the type of the object. Then anytime you have a polymorphic function (an override) you dispatch on it using a case. Does that make it clearer? I thought the base class TAnimal would have this “type” enum set at construction and it would be available at runtime. Regards, Ryan Joseph _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel