[fpc-devel] Class helper: small differences between FPC and Delphi

Sven Barth pascaldragon at googlemail.com
Fri Mar 25 22:33:06 CET 2011


Hello together!

While cleaning up the tests a bit (splitting them in "class helper", 
"record helper" and "general" tests) I noticed two small differences in 
my implementation and that of Delphi.

1. Record helpers in Delphi don't support inheritance. In FPC they do 
and I believe (see point 2) that record helpers in Delphi could support 
that as well, but it's been disabled on purpose. I personally think that 
inheritance for record helpers increases their use, because you can work 
around the "one helper per type" problem by using inheritance.

So I will definitely keep that "feature" in, but the question is whether 
I should forbid this in mode Delphi...

2. In Delphi helpers are based on classes and in FPC they are a seperate 
type. I've choosen the later, because it has reduced the need for some 
checks and also simplified the code.
I noticed the difference when checking the RTTI parent reference of a 
class helper (I had already checked that it is of type tkClass, but 
haven't thought more about it): the result was that all helpers (class 
and record) inherit from a class TClassHelperBase which in turn inherits 
from TInterfacedObject.

As I honestly don't want to rebuild my entire implementation (now that 
I'm basically finished and everything works) I'm proposing the following 
clean - but Delphi incompatible - solution: I introduce a new RTTI kind 
tkHelper of which the helpers will be a type of. It will be similar to 
classes, but the parent of a not inherited helper will be Nil (I could 
add a reference to the extended type as well).

I believe that this won't have that much impact on Delphi code as RTTI 
of helper's shouldn't be used that often (at least a quick googling 
reveals that people mostly want to use the RTTI to see all helpers that 
apply to a type - which isn't possible).

Regards,
Sven



More information about the fpc-devel mailing list