3 ms·
The two reasons for tail calls are loops and CPS. Nobody is championing the idea that we need traces for each loop iteration. I would somewhat understand the CP
by hajile 11y ago
The two reasons for tail calls are loops and CPS. Nobody is championing the idea that we need traces for each loop iteration. I would somewhat understand the CPS argument except that the event loop already destroys a huge amount of meaningful stack traces anyway (while not identical, it is somewhat similar). I don't see anyone insisting on stack traces there either.
Why do we need explicit tail calls with stack traces?
- nostrademons 11y agoThat's an argument in favor of explicit tail call syntax. If there are only two main use-cases (loops and CPS), then why not annotate those two use-cases and leave everything else untouched? The problem with implicit tail call syntax is that suddenly stack traces will be elided from debugging info when you really just wanted a normal function call that happened to be in tail position. These are really hard-to-track-down bugs, since the stack frame that is elided is precisely the one that made the tail call.
- bzbarsky 11y agoBrowsers are adding stack traces across the event loop, precisely because people _do_ commonly want them.