问题描述
我有一个大量使用尾递归(用 F# 编程)的 .NET 4.0 应用程序.它在 .NET VM 上运行良好,但在 Mono-3.0.1 上运行出堆栈.
I have a .NET 4.0 application that makes heavy use of tail recursion (programmed in F#). It runs fine on the .NET VM, but it runs out of stack on Mono-3.0.1.
我尝试过使用 mono --optimize=tailc
运行,但这似乎并没有改变任何东西.
I've tried running with mono --optimize=tailc
but that doesn't seem to change anything.
有没有办法强制单声道消除尾音?有没有办法增加单声道的最大堆栈大小?
Is there some way to force mono to eliminate tail calls? Is there some way to increase the maximum stack size in mono?
推荐答案
最近有一个非常相似的问题有帮助:StackMono下的大小
There is a very similar more recent question with helpful answers: Stack size under Mono
正如 Robert Harvey 在评论中已经指出的那样,Mono 对 F# (错误 476785:F# 中的尾调用支持).在 Mono 的运行时进行中的项目列表中对此问题的修复.
As Robert Harvey already pointed out in the comments, Mono has broken/incomplete tail call support for F# (bug 476785: Tail call support in F#). Fix for this problem is on Mono's runtime ongoing projects list.
可以使用 System.Threading.Thread
构造函数或在 PE 标头中增加堆栈大小.但是,System.Threading.Thread
方式 在 Mono 中不起作用.要更改 PE,您可能会 需要 MS Visual Studio,因为它的 editbin.exe/stack
.
Stack size can be increased either using System.Threading.Thread
constructor or in the PE header. The System.Threading.Thread
way does not work in Mono, though. For changing the PE, you'll probably need MS Visual Studio, since there may be no alternative to its editbin.exe /stack
.
这篇关于Mono 中的尾调用消除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!