Meta-circular evaluator

Meta-circular evaluator

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.

The idea goes back at least to the definition of Lisp 1.5 (1961) by John McCarthy.[1] He describes the evaluation rules of Lisp as a Lisp program.

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.[2]

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, "The significance of the meta-circular interpreter". 2006-11-22. http://weblog.raganwald.com/2006/11/significance-of-meta-circular_22.html. Retrieved 2011-01-22. 

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

Ramifications

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.

Examples

Many languages have one or more meta-circular implementation.

Languages with a meta-circular implementation designed from the bottom up, in grouped chronological order:

Languages with a meta-circular implementation via third-parties:

Languages with a meta-circular implementation via other means:

See also

References

  1. ^ Definition of EVALQUOTE in Lisp 1.5 Programmer's Manual
  2. ^ Gilbert, Philip (1977). Notes on Program Design Techniques. Reseda, CA: Ridgeview Publishing Company. p. 7.7. 
  3. ^ Meta-circular implementation of the Pico programming language

External links

Structure and Interpretation of Computer Programs (SICP), online version of full book, accessed 2009-01-18.


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Circular — is a basic geometric shape such as a Circle. Contents 1 Documents 2 Travel and transportation 3 Places …   Wikipedia

  • Circular definition — A circular definition is one that uses the term(s) being defined as a part of the definition or assumes a prior understanding of the term being defined. Either the audience must already know the meaning of the key term(s), or the definition is… …   Wikipedia

  • Self-interpreter — A self interpreter, or metainterpreter, is a programming language interpreter written in the language it interprets. An example would be a BASIC interpreter written in BASIC. Conceptually, self interpreters are closely related to self hosting… …   Wikipedia

  • Prolog — infobox programming language paradigm = Logic programming year = 1972 designer = Alain Colmerauer implementations = BProlog, ECLiPSe, Ciao Prolog, GNU Prolog, Quintus, SICStus, Strawberry, SWI Prolog, YAP Prolog, tuProlog dialects = ISO Prolog,… …   Wikipedia

  • Interpreter (computing) — In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language. An interpreter may be a program that either executes the source code directly translates source… …   Wikipedia

  • Common Lisp — Paradigm(s) Multi paradigm: procedural, functional, object oriented, meta, reflective, generic Appeared in 1984, 1994 for ANSI Common Lisp Developer ANSI X3J13 committee Typing discipline …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”