last call optimisation

last call optimisation

(programming)(Or "tail call optimisation") Discarding theimmediate calling context (call stack frame) when the lastaction of a function or procedure, A, is to call anotherfunction or procedure, B. B will then return directly to A'scaller, or possibly further up the call stack if theoptimisation has been applied to several consecutive calls.

Last call optimisation allows arbitrarily deep nesting ofprocedure calls without consuming memory to store uselessenvironments. This is particularly useful in the special caseof tail recursion optimisation, where a procedure's lastaction is to call itself (possibly indirectly).