Caterpillar

Daily Thought - 2024-08-24

< back to list

A while ago, I started talking about tail call elimination, before I got distracted and spent the next weeks talking about (and implementing!) pattern-matching functions instead.

So, Caterpillar does tail call elimination, happily omitting useless stack frames left and right. That's great! But what if your program hits a breakpoint, or some error condition? You would expect to see where that error happened, where the function was called from, where that function was called from, and so forth.

But where is the debugger supposed to get that information from? Well, the call stack. The same call stack that is full of gaps, thanks to tail call elimination. And showing information that's full of gaps is going to confuse the developer, which won't do. The solution to that problem is call stack reconstruction, and that's what I'd like to tackle next.

<< previous thoughtnext thought >>