Some languages, such as
Java and
PHP, have an explicit
reflection subsystem which allow access to internal implementation structures even though they are not accessible or manipulable in the same way as ordinary objects. In other languages, such as those in the
Lisp family, reflection is a central feature of the language, rather than a special subsystem. Typically this takes the form of some set of the following features: •
syntactic macros or
fexprs - which allow the user to write code which handles code as data and evaluates it by discretion, enabling, for example, programs to write programs (or rewrite themselves) inside of the compiler, interpreter, or even the parser (
reader macros); • a
meta-circular evaluator - which provides a definition of the language's
evaluator as a compiled tautologisation of itself, facilitating straightforward modification of the language without requiring a
metalanguage different from itself; • a
metaobject protocol - a special form of meta-circular evaluator for
object-oriented programming, in which the object system implements itself recursively via a system of metaclasses and metaobjects, which are themselves classes and objects. These allow varying forms of first-class access to the language implementation, and are, in general, manipulable in the same way as, and fully indistinguishable from, ordinary language objects. Because of this, their usage generally comes with some (cultural) stipulations and advice, as untested modification of the core programming system by users can easily undermine performance optimisations made by language implementers. == See also ==