Crosscut

Daily Thought - 2025-03-19

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!

Rust is rather strict about pattern matching: You always have to match every possible case. So if you match on an enum, you have to cover all of its variants. And all match arms have to return the same type. I don't think that's the only way to do it.

Let's say you have a variant { A, B, C } but your match expression only covers A and B, and always returns X. If we wanted, the compiler could accept this partial match, and the result would be a variant { X, C }. If the match arms returned either X or Y instead, this could result in a variant { X, Y, C }.

In such a system, variant types would be more closely tied into the language than enums are in Rust. In Rust, it's always an error, if the "then" and "else" branches of an if expression return different types. But we could decide that in Crosscut, this case results in a variant.

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 every time I post a new one.