Pranav
Pranav

Reputation: 3312

Conditions for a meta-circular evaluator

Are there any conditions that a language must satisfy so that a meta-circular evaluator can be written for that language? Can I write one for BASIC, or for Python?

Upvotes: 2

Views: 167

Answers (2)

Keith Gaughan
Keith Gaughan

Reputation: 22705

To quote Reg Braithwaite:

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.

Given that, one of the key features of a language that allows meta-circular interpreters to be written for them is homoiconicity, that is, that the primary representation of the program is a primitive datastructure of the language itself. Lisp exhibits this by virtue of the fact that programs are themselves expressed as lists.

Upvotes: 3

Svante
Svante

Reputation: 51551

You can write it for any language that is Turing-complete, however, your mileage may vary.

For Python, it has been done (PyPy). A list of languages for which it has been done can be found at the Wikipedia article.

Upvotes: 0

Related Questions