Daily Thought - 2024-08-25
Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!
This thought was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.
Tail call elimination leaves gaps in the call stack that will confuse the developer, when they're looking at an error in the debugger. For Caterpillar, with its focus on interactivity, immediacy, and intuitiveness, this is an unacceptable trade-off. Fortunately, there seems to be a solution: call stack reconstruction.
Let's start with the simple case (which is already implemented): main
is the
entry point to every Caterpillar program, so if the call stack doesn't start
there, you know something's missing. (In the future that will probably depend on
the host, but for now it's true. Either way, the debugger only runs when a host
is present, so it can rely on host-specific knowledge.)
The fix is easy: Just add main
to the start of the call stack. The debugger
also shows which expression within an active function called the next one, but
that's easy too: The stack frame was optimized away by tail call elimination, so
it must have been a tail call. We can mark the last expression in main
as
the active one, and we're done.
Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email whenever I post a new one.