Re:Tail Call Improvements in .NET Framework 4
by scott_s on Tuesday March 09, 2010 @04:33PM
(#1179447)
You and I have a different definition of "semantics" when it comes to programming languages. Your code still achieves the same result, just in a different way. That requirement - equivalent outcome - is how compilers decide what optimizations it can and can't perform. This is often stated as "optimizations can't change program semantics."
[ Parent
| on HN ]
Re:Tail Call Improvements in .NET Framework 4
by bad_user on Tuesday March 09, 2010 @04:51PM
(#1179495)
If an optimization means that an algorithm reaches the desired result or not, that's not an optimization anymore.
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.