Introduce an annotation to rewrite mutually recursive functions to use a trampoline. This will enable the user to avoid exceeding the stack size at the expense of more overhead until ES6 proper tail calls are widely implemented (it is only available in Safari 10 & WebKit at the moment).
after we upgrade 4.04 we have more fine control over the inlining info and tail call annotation.
And in 4.04 we will optimize local exception into a jump. so we will wait until 4.04 upgrade finishes.
Note we have baked in conditional compilation in case you need a workaround http://bloomberg.github.io/bucklescript/Manual.html#_conditional_compilation_support_static_if
Note that newer versions of node support tail call optimization in accordance with the ES6 spec. Here is a demonstration.
Hi! Any updates on this? I have a parser generated with Menhir and it gives me a stack overflow whenever I try to run it on a real-world amount of Lua code. Node 8 removed the tail calls flag, so I'm left with no solution.
I see occasional mentions of adding trampolines but I think it's still a long-term plan. My app has a small enough JS surface area that I was able to switch to js_of_ocaml to get trampolining. I kept the Bucklescript compile path for development, though, and I look forward to being able to use it for production eventually 馃槈
Watching. I would love to see trampolines added.
Most helpful comment
after we upgrade 4.04 we have more fine control over the inlining info and tail call annotation.
And in 4.04 we will optimize local exception into a jump. so we will wait until 4.04 upgrade finishes.
Note we have baked in conditional compilation in case you need a workaround http://bloomberg.github.io/bucklescript/Manual.html#_conditional_compilation_support_static_if