lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> It is very easy for a compiler to identify tail calls in a Lua source.

Yes, it is. But as I said before, a tail call will not always executes as a 
"proper" tail call, because of C functions.

Again, it is easy for the interpreter to test whether the called function 
is C or Lua, and act accordingly. The real problems I see for tail calls in 
Lua are

1 - debugging. Many Lua users do not even know what is a tail call, and
expect to see them in a stack trace.

2 - subtle behaviour. "return f()" is a proper tail call (*if* f is a Lua
function), but "return x, f()" and "f(); return" are not. This can be
quite confusing for programmers assuming proper tail calls.

-- Roberto