IT lexicon › Programming › Thunk

Thunk

Programming På svenska → Updated: 2026-11-06

A small compiler-generated stub that sits in the path of a call and does some little job before — or instead of — the real work.

The word goes back to ALGOL 60. Call-by-name meant an argument had to be re-evaluated every time it was used, and Peter Ingerman described in 1961 how to do it with tiny helper routines. The name supposedly comes from the expression having already been "thunked about" at compile time. The idea lives on in lazy languages such as Haskell, where every not-yet-evaluated value is a thunk.

In compiler land the word now covers almost any middleman. C++ with multiple inheritance puts thunks in vtables to adjust the this pointer before jumping on. Windows 95 thunked between 16- and 32-bit code. The 2018 Spectre mitigation retpoline routes every indirect branch through __x86_indirect_thunk. What they share is that no human wrote them and they only show up in a stack trace.

← Back to the lexicon