ABSTRACT

The first stage toward computational reflection requires that the programs have access to information about themselves. The ability for a program to access information about itself is called introspection. Not all programming languages support introspection, but some do. Python has powerful introspective functions, some of them built-in and others provided by modules such as the inspect module. Other languages that support introspection provide similar facilities, even if the APIs are very different. These facilities open the door to an entire new dimension of program design, one that takes the program itself into account. However, the use of introspection adds an additional indirection to programs that is not always desirable, and that may make the programs hard to understand. Introspection should be avoided, unless the alternatives are worse.