首页 文章

递归函数和使用F#的断点

提问于
浏览
1

请考虑以下代码:

[<EntryPoint>]
let main (args: string []) = 

  let rec main time =
    let newTime = time + 2 // place a breakpoint at this line
    main newTime

  main 0

我无法在标记线上放置断点 . 我在使用递归函数时经常遇到这些问题,它确实让我不使用它们 . 那有什么简单的解决方案吗?

编辑:我创建了一个全新的解决方案,我的构建命令如下所示:

'------ Build build:Project:ConsoleApplication4,Configuration:Debug x86 ------ C:\ Program Files(x86)\ Microsoft F#\ v4.0 \ fsc.exe -o:obj \ x86 \ Debug \ ConsoleApplication4.exe -g --debug:full --noframework --define:DEBUG --define:TRACE --doc:bin \ Debug \ ConsoleApplication4.XML --optimize- --tailcalls- --platform:x86 -r:“C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ FSharp \ 2.0 \ Runtime \ v4.0 \ FSharp.Core.dll”-r:“C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ mscorlib.dll“-r:”C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ System . Core.dll“-r:”C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ System.dll“-r:”C:\ Program Files(x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ Profile \ Client \ System.Numerics.dll“--target:exe --warn:3 --warnaserror:76 --vserrors --LCID:1033 --utf8output --fullpaths --flaterrors“C:\ Users \ olsv \ A. ppData \ Local \ Temp.NETFramework,Version = v4.0,Profile = Client.AssemblyAttributes.fs“Program.fs ConsoleApplication4 - > d:\ olsv \ documents \ visual studio 2010 \ Projects \ ConsoleApplication4 \ ConsoleApplication4 \ bin \ Debug \ ConsoleApplication4 .exe ==========构建:1成功或最新,0失败,0跳过=========='

2 回答

  • 0

    我尝试调试你发布的代码,它似乎工作得很好(我正在使用Visual Studio 2010 SP1) . 当我放置断点并运行代码(作为控制台应用程序)时,它会在断点处重复停止,我可以跳到下一个表达式并查看局部变量的状态 .

    您可以尝试检查编译器标志 - 当您禁用优化和尾调用时,调试效果最佳(这可能与递归函数特别相关) . 当我构建项目时,标志包括以下内容: --debug:full --optimize- --tailcalls- .

    enter image description here

  • 4

    所以它看起来像是一个bug . 我已经向F#团队报告过了 . 所以,希望他们能尽快修复它!

相关问题