Tail recursion in C#

added by tom103
9/7/2011 2:40:16 AM

6 Kicks, 235 Views

This article briefly explains what tail recursion is, and explores various ways to implement it in C#.


8 comments

dpeterson
9/7/2011 9:03:18 AM
The F# compiler does in fact support tail recursion correct? Do you think it's a better approach to mix F# and C# or to implement one of the methods you outlined in C#?

tom103
9/7/2011 9:09:50 AM
I don't know much about F#, but according to this article by Bart de Smet, the F# compiler transforms recursive tail calls to loops. For non-recursive tail calls, it uses the tail IL instruction
http://bartdesmet.net/blogs/bart/archive/2009/11/08/jumping-the-trampoline-in-c-stack-friendly-recursion.aspx
tom103
9/7/2011 9:09:54 AM
I don't know much about F#, but according to this article by Bart de Smet, the F# compiler transforms recursive tail calls to loops. For non-recursive tail calls, it uses the tail IL instruction
http://bartdesmet.net/blogs/bart/archive/2009/11/08/jumping-the-trampoline-in-c-stack-friendly-recursion.aspx
tom103
9/7/2011 9:09:56 AM
I don't know much about F#, but according to this article by Bart de Smet, the F# compiler transforms recursive tail calls to loops. For non-recursive tail calls, it uses the tail IL instruction
http://bartdesmet.net/blogs/bart/archive/2009/11/08/jumping-the-trampoline-in-c-stack-friendly-recursion.aspx
tom103
9/7/2011 9:10:07 AM
I don't know much about F#, but according to this article by Bart de Smet, the F# compiler transforms recursive tail calls to loops. For non-recursive tail calls, it uses the tail IL instruction
http://bartdesmet.net/blogs/bart/archive/2009/11/08/jumping-the-trampoline-in-c-stack-friendly-recursion.aspx
tom103
9/7/2011 9:10:47 AM
Sorry about the duplicate reply... I'm having connection problems, and it didn't seem to work the first time
vijayst
9/11/2011 9:49:16 AM
Good article. thanks.