logoalt Hacker News

tialaramextoday at 12:38 PM3 repliesview on HN

This footgun is the reason I'm so enthusiastic about the Rust `become` keyword.

This proposal would give Rust a specific keyword which says that you intend TCO and so two things happen: 1. The compiler goes to more length to deliver TCO even where it wouldn't "just work" and 2. If it cannot deliver TCO your code doesn't compile, because you asked for TCO.


Replies

jmalickitoday at 4:04 PM

Does 1 really happen? I would never trust a compiler where 1 was a possibility. If it can work it should.

chriswarbotoday at 12:53 PM

Sounds similar to @tailrec in Scala

I personally use the phrase "tail call elimination" when it's a requirement that can be relied on; and "tail call optimisation" when it might be implementation-dependent, context-dependent, limited (e.g. to immediate self-calls), etc.

show 1 reply
StilesCrisistoday at 12:43 PM

Sounds like clang::must_tail?

show 1 reply