3 ms·
I think this is the first time I am disagreeing with a comment of yours. Sadly, this factually incorrect position about TCO is held by many and repeated often.
by srean 11y ago
I think this is the first time I am disagreeing with a comment of yours. Sadly, this factually incorrect position about TCO is held by many and repeated often.
On the larger scheme (pun intended) of things, of course TCO is not essential, very few things are. However, the assertion "you can just always use a loop" is incorrect. To pull out just one example, with TCO I can have the producer-consumer coroutine for free without stack overflow. Loops are not the only use case for TCO.
Furthermore, there is nothing 'O' about it, doing extra work (maintaining call frames) not required by the semantics is not an optimization but an act of pessimization, unless there are compelling reasons to do that extra work. Guido feels lack of stacktraces is one such a compelling reason. I don't find that to be particularly compelling because that 'stack trace' is quite absent in the alternative he suggests: loops
- StefanKarpinski 11y agoGood point about it not being an optimization – calling it "tail call elision" would be more correct. And it's true, as @pflanze's comment correctly points out and I think you're getting at, that loops aren't sufficient – but gotos are. Of course, then you're programming with gotos, which may not be awesome. But point taken.