Daily Thought - 2024-07-13
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.
I've been talking about linear types over the last few days, but I've kinda beaten around the bush on one topic: How do you eventually deal with a value of a linear type? You can't keep moving it somewhere else forever.
Let's look at an error, for example, that you received as a return value. You can pass it to another function, to handle it there. You can return it again, to have it handled by the caller. Or you can store it in a list, which means you'll be forced to handle the list eventually. But at some point, you need to deal with the value once and for all.
And you can do that by destructuring it, breaking it up into its component parts. (This is the thing that happens when you do pattern-matching in Rust, for example.) You could also make those component parts private, and force that destructuring to happen in the same module where the type is defined. Then the developer would have to call a function there, to handle the error.
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.