Why doesn't .NET/C# optimize for tail-call recursion? -


I have found out which language is to optimize tail recursion, why C #, whenever possible tail does not optimize recursion is?

For a solid case, why this method is not optimized in a loop (32-bit, if it matters) ?:

  Private static zero foo ( Int i) {if (i == 1000000) back; If (i% 100 == 0) console Wrightite (i); Foo (i + 1); }  

A difficult balance between spending too much time in compiling GIT compilation The phase (thus becoming slower in the short lifetime) vs vs versus versus vs. In order to keep the application competitive, do not do enough analysis with a standard advance-time compilation.

Interestingly, the compilation steps are not targeted, because of their aggression in their optimization, I suspect this because they simply do not want to make a bug where behavior is dependent on whether JIT or NGN was responsible for machine code.

Self-supporting tail call optimization, but language-explicit compiler should know how to prepare the relevant and JIT should be ready to respect it. The FSC will generate relevant backups (though for a simple recurrence it can convert the entire thing directly to while in the loop). C # does not do CSC.

See some details (quite possibly now according to recent JIT changes) Note that CLR varies for 4.0.


Comments