|
|
|
|
|
by tigershark
3745 days ago
|
|
Yes, I agree, but you need to be really careful about tail call recursion optimisation when calling f# code from c#.
In F# it is always guaranteed, in c# only on 64 bit 4 and above runtime if I remember correctly, so you can't really rely on it for production code. |
|
The F# compiler used to emit "tail." prefixes in every case that was eligible. But not only does the CLR have lots of restrictions, it was slower to request tailcalls.
Maybe that changed in the last version or two.
Edit: OK I found the email where I had asked fsbugs why tailcalls were no longer generated. But that was in 2009 so I'm more out of date than I remember.
In the release notes[1] for the May 2009 release, there's this section:
Optimizations for Tailcalls
On some implementations of the CLI, normal calls can be more efficient than tailcalls. An optimization is now applied to determine if a function is “closed” in the sense that it never takes any tailcalls outside a finite non-recursive callgraph. If so, the use of tailcalls is suppressed.
1: http://blogs.msdn.com/dsyme/archive/2009/05/20/detailed-rele...