Daily Thought - 2025-03-15
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 tracks which fields of a struct have moved. Crosscut could do the same for its records, but would that actually be necessary? Having thought about it some more, this whole notion of moving a value out of a field (and moving one back in) only makes sense, if structs are mutable. In Crosscut, records (and any other value) definitely wouldn't be.
So what would that look like, if a language with immutable values had a linear type system? Then moving a field out of a record would create a new value, just like any other modification would. And in this specific case, that new value would have a different type.
Let's say you have a record of type record { a: A, b: B}
, and move the value
out of the a
field. Then the updated record would be of type
record { b: B }
. You could move another value of type A
back in, to replace
the original one, and the result would be a record { a: A, b: B }
again.
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.