A tail-call interpreter in (nightly) Rust

April 6, 2026
Detailed close-up of a camouflaged lizard with a curved tail basking on a rock.
Photo by Mahamevnawa Buddhist College on Pexels

What happened

Matt Keeter posted a deep-dive on building a tail-call–friendly interpreter using Rust's nightly toolchain. The write-up walks through a compact implementation that avoids growing the native call stack for tail calls by structuring the interpreter around trampolines/generators and other unstable Rust features. It has been reported that the post includes runnable examples and a link to source code, and that the approach runs on current nightly compilers rather than stable Rust.

Why it matters

Tail-call optimization (TCO) is one of those features beloved by functional-language people — think Scheme’s guarantee that tail calls never consume stack — but Rust has never offered TCO at the language level. Keeter’s work shows a practical way for language implementers to get the same effect inside an interpreter written in Rust: you don't need magic from the compiler to preserve constant stack usage, just careful control of control flow. Of course, this relies on unstable APIs, so it's a neat tool for prototype and research work, not yet a drop-in for production libraries targeting stable toolchains.

Community and context

The post has been discussed on Lobsters and around the PLT crowd, where readers are asking the obvious question: will this pattern push anyone to change Rust’s priorities on tail calls? Probably not overnight. But it does join a growing list of creative uses of Rust nightly — async/generators, Pin, and the like — to implement language runtimes. Allegedly, some readers reported promising microbenchmarks, though that will need independent verification before anyone treats this as a performance claim.

Want to run a tail-recursive interpreter in Rust today? You can, if you’re willing to live on the bleeding edge. For language hackers, that’s roughly equivalent to a pot of gold. For everyone else: take notes, watch the api stabilization process, and maybe keep an eye out for a cleaned-up version that works on stable Rust someday.

Sources: mattkeeter.com, Lobsters