FANDOM


A tail call is a language specific return value optimization, implemented mainly in functional programming languages. It works by destroying a function off of the stack as soon as it returns a function call. In simpler terms, when the return value is coming from another function being called, the compiler will shift work over to the proper procedure as to save time and memory.

Examples Edit

Lua Edit

-- a pointless function
function x()
    return 1;
end

-- another pointless function...
function y()
    return x(); -- since the return value is a function call, it will destroy 'y' and move to 'x'
end

y() -- calls 'y', but in reality, you're calling 'x'
16px-Pencil

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.