# Reflection

Logtalk provides support for both structural and behavioral reflection. Structural reflection supports computations over an application structure while behavioral reflection computations over what an application does while running.

## Structural reflection

Structural reflection allows querying the properties of objects, categories, protocols, and predicates. It is materialized by an API that supports all the developer tools, which are regular applications. This API provides two views on the structure of an application: a transparent-box view and a black-box view, described next.

### Transparent-box view

The transparent-box view provides a structural view of the contents and properties of entities, predicates, and source files akin to accessing the corresponding source code.

For entities, built-in predicates are provided for enumerating entities, enumerating entity properties (including entity declared, defined, called, and updated predicates), and enumerating entity relations. For a detailed description of the supported entity properties, see the sections on object properties, protocol properties, and category properties. For examples of querying entity relations, see the sections on object relations, protocol relations, and category relations.

The logtalk built-in object provides predicates for querying loaded source files and their properties.

### Black-box view

The black-box view provides a view that respects entity encapsulation and thus only allow querying predicates and operators that are within scope of the entity calling the reflection methods.

Built-in methods are provided for querying the predicates that are declared and can be called or used as messages and for querying the predicate properties. It is also possible to enumerate defined entity entity operators. See the sections on finding declared predicates and on predicate properties for more details.

## Behavioral reflection

Behavioral reflection provides insight on what an application does when running. Specifically, by observing and acting on the messages being exchanged between objects. See the section on event-driven programming for details. In addition, the logtalk built-in object provides predicates for handling debug events.