Markus Gerwinski wrote:
Nevertheless I'd like to have a way to check the validity _before_ casting, thus preventing the runtime error in cases where I don't want the program to be interrupted.
Currently, I'd suggest the following additional functions in GPC itself:
Function getObjectType ( obj: object ): "type";
There's (BP compatible) `TypeOf (ObjectType or ObjectVariable)' (returns a pointer which should be considered meaningless except for the fact that it's the same for same types), so you could check `if TypeOf (foo^) = TypeOf (tBar)', but this will fail on subtypes of tBar.
Function isOfObjectType ( obj: object; runtimeType: "type" ): boolean;
That's `obj is type'. The status of `is' is the same as of `as' (i.e., don't hold your breath)...
Frank