There is a TypeInfo function in the TypInfo unit
I was using it another day:
TTypeInfo(TypeInfo(S)^).Name;
Please note that it's a bad idea to store a
TTypeInfo value into a variable as quite some information is invisibly attached to the data (e.g.
GetTypeData() would provide incorrect values if you'd use it on such a variable). So better use the
PTypeInfo type:
PTypeInfo(TypeInfo(S))^.Name;
@Tikani: yes, RTTI works as expected in generics (though there might be some bugs here and there, but they should be few and far inbetween
). Trunk now even supports the
GetTypeKind() intrinsic which directly returns the
TTypeKind value of the type or variable as a constant and thus allows for constant folding in if- or case-statements.