Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My understanding is that it's the opposite -- function calls expend a cost to save (and later restore) the registers and push the locals onto the stack. Tail recursive functions on the other hand can be implemented as a jump to the top of the function, right after all the stack bookkeeping, and so saves on that expense.


Tail-merging doesn't only apply to recursive functions. As soon as you don't need to store intermediate result, you can jump to another function without allocating a frame.


Yes, this is right




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: