from Hacker News

Things you can’t do in Rust: tail recursion

by andrew-lucker on 12/1/17, 2:50 AM with 5 comments

  • by stmw on 12/1/17, 10:00 AM

    Do people often rely on tail-recursion for real-world programs? Before anyone wonders if I know what it is, yes, I do, and yes, I've used it appropriately, but it feels so... academic.
  • by fulafel on 12/1/17, 6:11 PM

    This example is just infinite recursion. You will get a similar result in, say, Python.

    Maybe the author wanted to say that Rust (currently) doesn't perform an optimization called tail call elimination that would make this program consume zero stack, which would make it hang instead of erroring out.

    Some languages (like Scheme) are specified to optimize tail calls, so you can rely on this behaviour there.