Various constructions can cause TeX (aka the lion) to go into an infinite loop. The simplest example is \def~{~}~, which defines ~ to expand to itself, then expands it. Now, if we exclude macro expansion, getting a loop is more difficult. With pure TeX, the two shortest methods I found (without macros) are
\everypar{\the\everypar}.
\toksdef~0~{\the~}\the~.
(including the trailing dots); note that the second is not macro expansion, but the expansion of \the\toks0 in hiding. With eTeX, I got down to
\if\unexpanded\fi
which has the additional "quality" of being expandable. Here, \unexpanded could be replaced by \detokenize or \scantokens.
- Why does that trigger an infinite loop?
- Is there a similarly short TeX constructions which does not use macro expansion (preferably only primitives)?
\if\unexpanded\fidoes. – Bruno Le Floch Feb 13 '12 at 21:11