CSC/ECE 517 Fall 2010/ch1 1c NR: Difference between revisions
Line 1: | Line 1: | ||
=Introduction to Reflection= | =Introduction to Reflection= | ||
Reflection was introduced by Brian Cantwell Smith as a framework for language extension | Reflection is a language feature that enables a program to examine itself at runtime and possibly change its behavior | ||
accordingly. Reflection was introduced by Brian Cantwell Smith as a framework for language extension.There are two aspects to reflection : | |||
*Introspection - the ability for a program to observe and reason about its own state. | *Introspection - the ability for a program to observe and reason about its own state. | ||
*Intercession - the ability for a program to modify its own execution state or alter its own interpretation or meaning. | *Intercession - the ability for a program to modify its own execution state or alter its own interpretation or meaning. |
Revision as of 01:17, 8 September 2010
Introduction to Reflection
Reflection is a language feature that enables a program to examine itself at runtime and possibly change its behavior accordingly. Reflection was introduced by Brian Cantwell Smith as a framework for language extension.There are two aspects to reflection :
- Introspection - the ability for a program to observe and reason about its own state.
- Intercession - the ability for a program to modify its own execution state or alter its own interpretation or meaning.
What is crucial here is that a given program can behave not only as a function, but also as a data structure that can be examined and manipulated to change its behavior. These properties lead to an easily extensible language since the structures used by the language implementation are accessible to the programmer. The programmer can now define programming constructs that would otherwise have been either impossible or extremely difficult to define. These properties have led to the adoption of reflection as a primary means for language extensibility. Reflection is most commonly used in many dynamically typed languages such as Ruby,Smalltalk, Objective-c and scripting languages like Perl,PHP. Statically typed languages such as Java, ML or Haskell also support reflection. Reflective programming languages and platforms provides a comprehensive list of all languages and platforms supporting reflection.