3 ms·
You absolutely should have knowledge of your target platform and whether it does TCO (and whether it kicks in for your code). Otherwise, you may decide to just
by ecma_horse 9y ago
You absolutely should have knowledge of your target platform and whether it does TCO (and whether it kicks in for your code).
Otherwise, you may decide to just use recursion everywhere and then your stack overflows when your N is bigger than expected.
When in doubt, don't use recursion and don't expect that you get TCO.
- xg15 9y ago> You absolutely should have knowledge of your target platform and whether it does TCO If I write web apps, as far as I'm concerned, my platform is V8, Whatevermonkey, Trident and every other hypothetical javascript engine out there, any of which might or might not support TCO under different circumstances. > When in doubt, don't use recursion and don't expect that you get TCO. I think relying on TCO is always a bad idea, exactly because you can't be sure your platform supports it. But STC doesn't change that. You can't expect the platform to support tail calls because you did some magic incantations. On the other hand, it doesn't make sense to me to forbid tail calls either. If you know your recursive code will work without TCO, it will work with TCO, too.