thunk
A thunk is a programming construct that represents a parameterless function which encapsulates a computation to be performed later. By capturing the necessary environment or arguments, a thunk delays evaluation and allows code to request the result at an indeterminate time. The term originated in early compiler literature, and its exact origin is informal, appearing in the 1960s and 1970s in discussions of delayed computation and call mechanics.
In lazy evaluation and functional languages, thunks implement deferred computation. A thunk wraps an expression so
Thunks are used in compiler design and foreign-function interfaces to adapt calling conventions or environments. A
In contemporary software development, the term appears in other contexts as well. A notable modern example
Overall, thunks provide a simple, flexible mechanism to encapsulate and control the timing of computations, offering