Meta-circular evaluator
From Wikipedia, the free encyclopedia
| This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. (September 2008) |
A meta-circular evaluator is a special case of a self-interpreter in which the existing facilities of the parent interpreter are directly applied to the source code being interpreted, without any need for additional implementation. Meta-circular evaluation is most common in the context of homoiconic languages.
A translator or interpreter (evaluator) is just a special kind of program, which can be processed like any other; and can therefore certainly be translated or interpreted by another translator or interpreter. Gilbert, Philip (1977). Notes on Program Design Techniques. Reseda, CA: Ridgeview Publishing Company. p. 7.7.
The difference between self-interpreters and meta-circular interpreters is that the latter restate language features in terms of the features themselves, instead of actually implementing them. (Circular definitions, in other words; hence the name). They depend on their host environment to give the features meaning.
– Reginald Braithwaite, weblog entry, "The significance of the meta-circular interpreter". 2006-11-22. http://weblog.raganwald.com/2006/11/significance-of-meta-circular_22.html. Retrieved on 2009-01-18.
Meta-circular evaluation is discussed at length in section 4.1, titled The Metacircular Evaluator, of the MIT university textbook Structure and Interpretation of Computer Programs (SICP). The core idea they present is two functions:
- Eval which takes as arguments an expression and an environment (bindings for variables) and produces either a primitive or a procedure and a list of arguments
- Apply which takes two arguments, a procedure and a list of arguments to which the procedure should be applied and produces an expression and an environment
The two functions then call each other in circular fashion to fully evaluate a program.
Contents |
[edit] Ramifications of meta-circularness
Meta-circular implementations are suited to extending the language they are written in. They are also useful for writing tools that are tightly integrated with the programming language, such as sophisticated debuggers. A language designed with a meta-circular implementation in mind is often more suited for building languages in general, even ones completely different from the host language.
[edit] List of meta-circular languages
Languages designed from the ground up with a meta-circular implementation:
Languages with third-party meta-circular implementations:
- Ruby via Rubinius
- Oz via Glinda
- Perl via eval()
- Python via PyPy
- Java via Jikes RVM, Squawk or Maxine[1]
[edit] See also
[edit] External links
- Structure and Interpretation of Computer Programs (SICP)
(online version of the entire book—accessed 2009-01-18)

