Reflection

“Reflection is an entity’s integral ability to represent, operate on, and otherwise deal with itself in the same way it represents, operates on, and deals with its primary subject matter.” — Brian Cantwell Smith

Reflective tower of interpreters include 3-LispBrownBlond, Black and more recently, co-created by me, Pink and Purple. A reflective tower of interpreters consists of a user level, interpreted by a meta level, interpreted by a meta meta level, and so on for potentially infinity. Reifying a program into data moves from a level (e.g. user) to the level above (e.g. meta), and reflecting data into a program back the other way. Pink and Purple demonstrate that one can collapse a tower of interpreters into a flat program, removing all interpretation overhead. Aside from reflective towers of interpreters, meta-object protocols (MOPs) have been successfully incorporated in languages like Common Lisp, Smalltalk and others. A MOP changes a language from a point in the design space to a subset of the design space. More recently, a MOP has been applied to virtual machines (VMs), leading to reflective VMs that can, for example, change the layout of memory on the fly based on what is most suitable for performance.