Is it a bug in Visual Studio? It is the first reaction in my mind, but after talking with Tao Liu, he told me the answer is No! Don't worry, it is because we forget that tail recursion is turned off by default when using Visual Studio and compiling in Debug mode, and how should we do now? Yeah, we can turn on it in project property:
- right-click the project properties in Solution Explorer, select 'Properties'
- go to the 'Build' tab
- make sure 'Debug' configuration is selected
- click the box 'Generate tail calls'
There is another way to workaround this exception, that is switch your program from 'Debug' mode to 'Release' mode. OK, now, just try to run your program again, you will see the real result you want.
Note: you can still find the answer here.
No comments:
Post a Comment