4 ms·
It's dead simple to tell apart a tail call. Does it look like return call(a, r, g, s) It is also very simple to test if the compiler does TCO. Just write
by rapala 12y ago
It's dead simple to tell apart a tail call. Does it look like
return call(a, r, g, s)
It is also very simple to test if the compiler does TCO. Just write
def f(a):
return f(a + 1)
f(0)
and wait for a stack overflow.
- justincormack 12y agoThat gives an indication, but not if it sometimes does TCO but not always (like gcc for C).
- lomnakkus 12y agoThe point here is the guarantee -- as specified by the language standard. There is no guarantee for TCO in C. The ES6 standard only guarantees the TCO for certain constructs which rapala's example showed (informally).