← Back to context

Comment by submain

3 hours ago

Great work :). Go doesn't have TCO. That means functional languages (no for loops) could blow up the stack. How did you solve that?

You can just compile any tail recursive function to a function with a loop and no recursion.

  • That does not address the use case where I find tail recursion most tempting. That would be mutually recursive functions.

    If the function can be written as an idiomatic loop I probably would do so in the first place.

  • This is in fact how Elm does it! Tail call recursion compiles to a while loop.