Someone else may come up with a better definition, but I think of reflection as the ability to reason about the structures and processes of a programming system within the programming system itself. Examples include the API's to Class objects in SmalltalkLanguage, JavaLanguage and the CommonLispObjectSystem.
--JeffMantei 2000-12-01
I mostly agree with this. I like to distinguish between a ReflectiveSystem (that contains a description of itself) and a CausallyReflectiveSystem. Changing the MetaInformation in a ReflectiveSystem typically merely breaks the system. Changing the MetaInformation in a CausallyReflectiveSystem causes a corresponding change in the behavior of the system. -- TomStambaugh
The ObjectOrientationFaq defines ReflectiveSystem as "systems with MetaObjectProtocols (not to be confused with reflexive systems, which often refer to systems implemented in terms of themselves, or bootstrapped)", and explains: "In CLOS terminology, an IntrospectiveProtocol provides a read only capability (e.g. what is this object's class, give info on this class, etc.) and an IntercessoryProtocol provides a write capability which allows system modification (e.g. add the following method or instance to this class, perform inheritance this way, etc.)."
Resources
A book called TheArtOfTheMetaObjectProtocol
See MetaObjectProtocol.
Discussion
Some issues possibly appropriate to this topic include:
- Do reflective capabilities overall help or hurt software development productivity?
- Is reflection for mere mortals, or should it be tightly limited?
- In what practical ways does reflection help in problems of design and/or refactoring?
- In what ways does reflection help support one or more AntiPatterns?
- What are various flavors/variations on reflection, and what are their pros and cons (e.g. read-only vs. updateable information)
One paper on CLOS (Bobrow, Gabriel, White 1993) mentions the following three aspects of reflection :
- Reification - the presentation of language concepts as "things" accessible to programs written in the language
- Introspection - the ability of a running program to "find out" about its own structure
- Intercession - the ability of a running program to alter its own (static) structure