A Couple of Meta-Interpreters in Prolog
Thank you very much for the publicity, I greatly appreciate it!<p>Prolog is rather unique in that it admits a meta-interpreter in roughly 3 lines of code.
Contrast this with other languages, where writing an evaluator typically takes much more code, even for quite high-level languages.<p>This brevity is possible mainly because Prolog - like Lisp and assembly language - is a <i>homoiconic</i> language, and in addition to that, Prolog has powerful built-in mechanisms that can be used in interpreters, and in addition to <i>that</i>, Prolog variables on the object-level (the program to be interpreted) are also variables on the meta-level (the interpreter). As a consequence, Prolog&#x27;s implicit mechanisms can be <i>absorbed</i> in interpreters: They need not be encoded explicitly.<p>Enjoy!