Tail Call Improvements in .NET Framework 4
extended64.com
extended64.com
I think it used to be that there was little perf difference between DEBUG and RELEASE builds, so for simplicity, with internal apps we always just build to DEBUG.
The above quote suggests that these days, they really are doing worthwhile optimizations in RELEASE builds. Does anybody know more about that?
TCO is not just a perf difference. Once you add it to a language, you've changed the semantics. The same piece of code will throw a StackOverflowException in DEBUG mode, yet functional perfectly in RELEASE. Scheme's spec requires TCO for this very reason.
def fact(n, r=1):
if n == 1: return r
return fact(n-1, r * n)
Regardless of any available stack-space you may have, for the above method (which can be tail-call optimized) try calculating fact(1000000). If that's the requirement, then without TCO this implementation is incorrect.- does this mean that it's possible to use TailCallHelper but still not be able to guarantee no stack overflow?
So yeah ... you have a guarantee, but it's also using stack space, so you have to watch-out for big arguments lists, because that may overflow the stack.
In that case I guess if you are running tail-recursion heavy algorithms on x64, just recompiling the same old code for the .NET 4 runtime should yield runtime improvements.
Would be interesting if someone had any actual measurements for this.