3 ms·
...the idea that TRE is merely an optimization, which each Python implementation can choose to implement or not, is wrong. Once tail recursion elimination e
by wk_end 2y ago
...the idea that TRE is merely an optimization, which each Python implementation
can choose to implement or not, is wrong. Once tail recursion elimination
exists, developers will start writing code that depends on it, and their code
won't run on implementations that don't provide it.
Someone should tell this to the amateurs over at GCC: https://godbolt.org/z/97s5afhsq https://godbolt.org/z/97s5afhsq
and Clang: https://godbolt.org/z/v384noWjq https://godbolt.org/z/v384noWjq
and Microsoft: https://godbolt.org/z/Wr5zrWT84 https://godbolt.org/z/Wr5zrWT84
and Intel: https://godbolt.org/z/5E7Mavf7h https://godbolt.org/z/5E7Mavf7h
As we all know, because these widely-used compilers treat TCO as an optimization, C programmers have become problematically insistent on using tail recursion instead of loops.
- grumpyprole 2y ago> As we all know, because these widely-used compilers treat TCO as an optimization, C programmers have become problematically insistent on using tail recursion instead of loops. I think you are misunderstanding. To put it another way: because, in C, the optimisation is not guaranteed, recursion is rarely used in practice. This is a shame as many problems do have a recursive structure and are best solved using recursion. It's probably the best decision for C, but not for a high-level language.
- deleted 2y ago[deleted]