Daily Thought - 2024-08-30
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.
Okay, so there are cases where call stack reconstruction won't work without further information. These cases can be detected at compile-time, so we can probably rely on the compiler to make sure we get the information we need.
Here's my idea: When the compiler detects such a case, it emits a special instruction that, when executed at runtime, leaves a hint on the call stack. It can't just do so unconditionally, because then we get unbounded stack growth in the presence of recursion. Just what tail call elimination is supposed to avoid in the first place.
So the instruction will have to check the stack first, and only add a hint if one isn't already there. This means there's going to be some performance overhead. I don't want to take this lightly. I want Caterpillar to work for a broad range of use cases, and that means it needs to be fast. But some overhead is acceptable, if it improves developer experience.
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.