Call By Thunk

CallByThunk is a technique for implementing ParameterPassing where a thunk (a small function, usually emitted by the compiler, which returns the intended argument after doing necessary processing - see WhatIsaThunk) is passed from the caller to the callee. When the callee wants to evaluate the argument, it calls the thunk which returns the value.

(The returned value can be either the value or a reference; so CallByReference and CallByValue can be implemented on top of thunks; this distinction isn't very useful. A thunk could, I suppose, return another thunk; but I've never heard of that being done).

Consequences:

Note. The Algol mechanism is officially called CallByName; which is a logical parameter passing method (that describes the semantics of Algol functions). CallByThunk is the underlying implementation technique; CallByThunk is used for many other purposes than implementing CallByName.

Exactly. CallByThunk is not a ParameterPassing mode, it's a way to implement some parameter passing modes. Nobody talks about CallByThunk, or programs in terms of CallByThunk, they talk about and program in terms of, CallByReference, CallByValue, CallByName, etc.


See also ParameterPassing, CallByReference, CallByValue


CategoryLanguageFeature


EditText of this page (last edited January 3, 2014) or FindPage with title or text search