Strange question but I heard it brought up during a discussion and I was very 
curious what compiler people think about it.

The question is, instead of using a virtual method table would it be feasible 
to use a case statement on the real class type and make a dispatch routine for 
each method call?

For example assume “type” is the internal type of the class (where a VTable 
would be) and a call to “animal.DoSomething()” is called which would internally 
basically be this dispatch table:

 case animal.type of
   TDog: TDog(animal).DoSomething;
   TCat: TCat(animal).DoSomething;
   TMouse: TMouse(animal).DoSomething;
 end;

The reason this was brought up was because virtual methods can’t be inlined and 
this would allow that but I think there would be more overhead overall to have 
all these case statements on every virtual method call.

Regards,
        Ryan Joseph

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to