Hacker News new | ask | show | jobs
by Spivak 1458 days ago
> There are many such interesting compositions that cannot be “unrolled”.

You're arguing semantics, sure, you cannot mechanically transform code which relies on TCO into a loop. That is not the same as the parents point that TCO functions are isomorphic to loops. In a language without TCO you wouldn't ever find yourself in mess of composition of functions.

2 comments

> You're arguing semantics, sure, you cannot mechanically transform code which relies on TCO into a loop.

TCO is how you mechanically transform recursive code into a loop.

> That is not the same as the parents point that TCO functions are isomorphic to loops.

That’s the same as claiming that manually copy-pasting the contents of functions into your code is isomorphic to calling those functions.

> In a language without TCO you wouldn't ever find yourself in mess of composition of functions.

Yes, that’s the point. There’s an entire class of useful constructions that cannot be implemented without TCO.

This argument happens enough that it should be considered its own fallacy "appeal to the turing tarpit".

By this logic, we should still be using GOTO because if we were, you'd never need to use loops.

Proper tail calls exist because they make the logic of a lot of things easier and more simple to follow.