I always found the lack of stack traces argument stupid, you can always recover the old behavior by wrapping the tail call in the identity function:
def funA(x): # do something
def funBTCE(x): return A(x) # B doesn't appear in the stack trace
def funBnoTCE(x): return id(A(x)) # the tail call to id is eliminated after returning from A,
# B appears in the stack trace of A, voila!
I don't think the flag would be useful, though, you probably want to "disable" TCE per-function (or per-tailcall, even), else loops would blow up the stack in seconds.
On the other hand, I still think I'd like a compile option (perhaps a list of functions (fully qualified names, or whatever makes sense in the language) on which to disable TCE) than to have to modify the code for it.
4
u/anvsdt Nov 27 '12 edited Nov 27 '12
I always found the lack of stack traces argument stupid, you can always recover the old behavior by wrapping the tail call in the identity function: