5 ms·
How will the affect the debugging of stack frames in javascript programs that utilize TCO?
by platz 12y ago
How will the affect the debugging of stack frames in javascript programs that utilize TCO?
- cwmma 12y agoin theory it could make them less informative, but I suspect in practice most engines that implement it will figure out a way to make stack frames usable with TCO
- vilhelm_s 12y agoScheme implementations have had to deal with this problem for a long time. (Of course, one can argue that languages with ordinary while loops have a similar problem, in that value of previous iterations of the loop get overwritten by later iterations). You can alleviate it by hanging on to stack frames for a while. Scheme48 heap-allocates stack frames, and then relies on garbage collection to reclaim space from tail-calls, so this happens automatically. And MIT Scheme uses a ring-buffer to keep around the last 10-or-so frames. (Actually it is even nicer than that: it uses ringbuffer-of-ringbuffers to keep 10-or-so frames from each of the last 10-or-so non-tail recursive calls. So when debugging you can pop up the call stack, and then at each level examine the last couple interations of the loops done at that level).