[fpc-pascal] Case statement for class introspection
Ryan Joseph
genericptr at gmail.com
Sun Jan 16 15:01:13 CET 2022
> On Jan 16, 2022, at 8:18 PM, Ryan Joseph <genericptr at gmail.com> wrote:
>
> https://gitlab.com/genericptr/free-pascal/-/commits/case_label_classref
I just realized too late that the way I implemented this may be not the best idea. If the class type had an ordinal representation then you could use a normal case statement instead of making a big if-else block and doing equality comparisons for each type. That would be faster right?
Assuming the memory address of the type worked you could do something like this behind the scenes:
case PtrUInt(o.ClassType) of
4500656856: writeln('TObject');
end;
If so, I would have to rethink this then and come back to it later.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list