开发者

Does C# do tail recursion? [duplicate]

开发者 https://www.devze.com 2023-03-28 17:37 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Why doesn't .net/C# eliminate tail recursion?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Why doesn't .net/C# eliminate tail recursion?

Does C# do tail recusion?

开发者_Python百科I can't find any documentation telling me if it does or not.


C# does not innately support tail recursion in the language but here is an interesting article on a similar technique call trampolining that may help you in your situation


Unfortunately, it does not, at least not yet.

I'm not sure if the standard itself specifies anything about (dis)allowing tail recursion. Regardless, since .Net supports tail recursion, so it would be nice for this to make its way into C#.

If you really need tail recursion in a .Net language, consider F# as an alternative.

0

精彩评论

暂无评论...
验证码 换一张
取 消