Chris Angelico wrote:
Which really says that TCO is impossible if you have any sort of clean-up or deallocation to be done after the call begins. The only way to truly turn your tail call into a GOTO is to do all your cleanup first.
Indeed. In compilers that implement TCO, there's quite a lot more to it than just "replace CALL with JMP". It requires rethinking your whole strategy on when to put various things on the stack and take them off again, so that by the time you get to the point of the tail call, there is nothing on the stack other than the arguments to the tail call and the ultimate return address. -- Greg -- https://mail.python.org/mailman/listinfo/python-list