New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unlimit recursive depth #237
Comments
|
@frokaikan Have you edited this post? Because I received another sample code: func f(a) {
System.print(a);
return f(a-1);
}
func main() {
return f(0);
}This is an unlimited loop because the user decided that it should be an unlimited loop. func fibonacci (n) {
if (n<2) return n;
return fibonacci(n-2) + fibonacci(n-1);
}
func main() {
return fibonacci(30);
}In this case the fibonacci function is recursively called more than 2.6 million times. How can I arbitrary set a 2014 limit? |
|
Eh, that is not me... I just want to know if I can set or modify the recursive depth limit. |
|
Fixed by 244c758 You can now control max depth recursion with System.maxRecursionDepth: func f(a) {
return f(a-1);
}
func main() {
System.maxRecursionDepth = 1024;
return f(0);
}
// RUNTIME ERROR: Max recursion depth exceeded for func f (limit is set to 1024) |
|
Thanks! |
This will cause an endless loop:
class foo {
func f1() {return 10;}
}
func main() {
var obj = foo();
var n1 = obj.f1();
}
I think there should be a recursive depth limit (such as 1024?)
The text was updated successfully, but these errors were encountered: