nam*_*zug 4 lua tail-recursion
每当我有一个函数在另一个函数的末尾调用时,我总是在返回的同一行调用它,就像这样return foo(x).
将结果分配给变量botch任何尾部优化的可能性?像这样,
function(...)
...
tmp = foo(x)
return tmp
end
Run Code Online (Sandbox Code Playgroud)
来自http://www.lua.org/pil/6.3.html : In Lua, only a call in the format return g(...) is a tail call..
所以在这种情况下你错过了尾调用优化是的.