Flambda2 Ep. 2: Loopifying Tail-Recursive Functions
ocamlpro.com
ocamlpro.com
I don't understand why anyone wouldn't want to convert the recursion to a loop? Surely it's always an improvement.
[1]: https://neopythonic.blogspot.com/2009/04/final-words-on-tail...
>if a function is not purely tail-recursive, but contains some tail-recursive calls then the transformation will rewrite those calls but not the other ones. This may result in better code but it's hard to be sure in advance. In such cases (and cases where functions become purely tail-recursive only after inlining), users can force the transformation by using the [@@loop] attribute
This has the obvious problem that you need to know a lot of details about the compiler to get the best performances, but this is the reasoning around that decision for now.