So basically I am processing a long list in Ocaml, and I got the Stack_overflow error.
Then I did this experiment, and the error re-occured.
let rec create l =
match l with
| 0 -> []
| _ -> "00"::(create (l-1))
let ll = create 999999; (*my list can be as long as around 100k*)
I use ocamlbuild to build this code into native, run it and then the code crushed and I got this:
Fatal error: exception Stack_overflow
So my question is that:
Can I extend the length of stack and avoid this error?
I know that
tail recursivecould help in this situation classically, but do I have to re-write my code thus enabletail-recursive? That would require a lot of manually modification... Could OCaml's compiler help in this issue?