[fpc-devel] .NET Reflection vs RTTI

Bram Kuijvenhoven kuifwaremailinglists at xs4all.nl
Wed Nov 21 22:33:30 CET 2007


Thorsten Engler wrote:
>> Apart from the custom attributes and the Invoke, I don't see 
>> what there is extra ?
> 
> No usable RTTI for records
> No usable RTTI for arrays
> No RTTI for private, protected and public(!) members (only published)
> No usable RTTI for published methods (param and return types are just given
> as strings, not as references to other type infos, no information about
> calling convention)
> No usable type information for published fields (only a name to offset
> mapping is given, no type information at all)
> And so on...

IMHO it would be very nice if the FPC RTTI system could be extended to support some of these things indeed.

My applications:
- streaming: for a custom input file format (that is more or less like JSON, but has a stronger typing mechanism etc.)
- scripting: easily expose parts of my program to a scripting engine, e.g. to Lua (see also pLua, http://eonclash.com/ViewProduct.php?ProductID=26)

My wishlist:
- support for dynamic/static arrays, e.g. property Items:array of string
- support for array properties, e.g. property Items[i:integer]:string (though perhaps less useful for streaming since the range of the index(es) is not known, it is very useful in scripting)
- support for records and pointers would also be nice
- support for method invocation (scripting)
  - support for calling a (parameterless) constructor instead of having to stick to NewInstance or some virtual constructor in a known base class (such as TComponent's Create)
- RTTI for public members (private and protected are internal to objects anyway; note also that fields are usually private in OOP designs)

Just my 2 cents,

Bram




More information about the fpc-devel mailing list