Crosscut

Daily Thought - 2024-09-05

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.

< back to list

The Caterpillar compiler handles errors in a way that is uncommon: If it encounters an error, it does not stop compilation. Instead it includes the error in whatever representation it's currently generating and moves on. For example, an unresolved identifier results in a special fragment, which then gets compiled into an instruction that triggers the respective error at runtime.

I didn't come up with this. I believe Roc is doing it too. Or at least Richard Feldman talked about this technique on his podcast. There are good reasons for doing it like this. While working on something, you might still want to run your tests, or check something in the debugger, even if some unrelated piece of code doesn't currently typecheck.

In Caterpillar specifically, an intermediate representation is also the basis for what's shown in the debugger (and maybe later, a custom editor?). This allows it to show an enriched form of the code, based on all the information that the compiler has figured out. It would be very inconvenient, if the tooling couldn't show any of your code, just because something in it is broken.

<< previous thoughtnext thought >>

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.