Interpreter-modifying

From Esolang
Jump to navigation Jump to search

A programming language is interpreter-modifying, reflective, or metacircular when there exists a metainterpreter which self-hosts the language and allows bidirectional communication between the interpreter and the interpreted program. The concept was formalized in 1996 by Kenichi Asai, Satoshi Matsuoka, & Akinori Yonezawa[1] with Black. They give the following criteria for a reflective language:

  1. User programs are allowed to access and change pre-determined parts of metalevel interpreters
  2. Reflection is available at every level
  3. The interpreter runs efficiently when reflection is not used or disabled
  4. The interpreter gracefully degrades under modifications

As a special case, a bytecode interpreter is interpreter-modifying when at least one of its instructions is (initially) assigned to an operation which can reassign an instruction to a new operation, register a new instruction, or register a new operation.

Examples

  • Black and its descendants, particularly Pink.
  • Emmental, which has a single instruction ! that changes the symbol to mean the same as sequence of symbols.
  • Mascarpone, which uses interpreters, symbols and operations af first-class data types.
  • Snowflake, which doesn't have any commands manipulating the interpreter, but each cycle an instruction is randomly modified. The language is generally peculiar, because both program and interpreter change permamently during execution. This leads to evolution of both program and interpreter, which become more and more optimized to themselves.
  • Unsmiley
  • Interpreterion, in which programs consist of interpreters.

References

  1. Asai, K., Matsuoka, S. & Yonezawa, A. Duplication and partial evaluation. Lisp and Symbolic Computation 9, 203–241 (1996). https://doi.org/10.1007/BF01806113