|
Wim Couwenberg wrote:
It would be great if tail calls could be made cheaper.
A jiter could easily recognise this special case of tail call recursion, converting it back in to a for/while loop. (The intermediate code would end up virtually identical), although tail calls in raw Lua can't really be improved upon.
If you really need it though, you could possibly write a function which'd modify the bytecode to remove the tailcall (and convert it in to a jump, loadnil and moves) but it'd be messy (it's a lot more complex then it sounds - you have to detect constant functions) and it wouldn't work with the debug library.
- Alex