views:

85

answers:

2

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?

A: 

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.

Svante
+2  A: 

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.

Keith Gaughan