Type introspection

Introspection should not be confused with reflection, which goes a step further and is the ability for a program to manipulate the metadata, properties, and functions of an object at runtime.

Some programming languages also possess that capability (e.g., Java, Python, Julia, and Go).

The method isKindOfClass: analogously returns true if the argument inherits from the specified class.

Now, in the eat method we can write Now, when eat is called with a generic object (an id), the function will behave correctly depending on the type of the generic object.

Deeper introspection (enumerating fields and methods) is traditionally only supported for objects declared in the $M+ (a pragma) state, typically TPersistent, and only for symbols defined in the published section.

For instance: Introspection can be achieved using the ref and isa functions in Perl.