Day 19 of Advent of Compiler Optimisations!

Recursive functions need to call themselves over and over — that must mean unbounded stack growth, right? Wrong! When a function ends by calling another function (even itself), the compiler can replace the call with a simple jump. Recursion becomes iteration, no stack overhead at all. How does this transformation work?

Read more: xania.org/202512/19-tail-call-
Watch: youtu.be/J1vtP0QDLLU

0

If you have a fediverse account, you can quote this note from your own instance. Search https://hachyderm.io/users/mattgodbolt/statuses/115746362725490077 on your instance and quote it. (Note that quoting is not supported in Mastodon.)