Self-referencing Programs

In WHILE there is no language feature that admits recursive macros or any direct reference to the program itself. This raises some questions. Can we write self-referencing programs in WHILE at all? More concretely, can we write a WHILE program that returns itself as data, i.e. its own abstract syntax tree? In this chapter Kleene’s Recursion Theorem, which answers those questions in the affirmative, is proved by one more application of the diagonalisation principle. Applications of the theorem are discussed and another theorem of Kleene’s, the parameterisation theorem, is shown, which provides the semantic justification of partial evaluation, a well-known program optimisation technique.