Hacker News new | ask | show | jobs
by fulafel 3122 days ago
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.

1 comments

To be clear about this, LLVM will sometimes do TCO. But Rust doesn't guarantee it. We have reserved a keyword to make this happen sometimes in the future, possibly.