Reflection is the ability for programs to examine themselves. In Step, this takes the form of predicates to answer questions like:
- Is my argument a task?
- What are the tasks in the program?
- What are the methods of this task?
- Have I called this task so far?
In programming languages, we often distinguish between static properties of the program, which examines the text of the program, and what can be determined from it without running it, and dynamic analysis, which analyzes the behavior of the program as it runs.
This is mirrored naturally in reflection capabilities. Static reflection tells you things about the text of the program: what tasks and methods does it have, what calls what, etc. Dynamic reflection tells you things about the program as it's running: what's running now? What was run previously?
We'll talk about each of these now, in turn.