Crosscut

Daily Thought - 2025-03-14

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!

Making all fields of structurally typed records public, and all fields of nominally typed ones private, would simplify the language. Making a single field public or private would simply not be a thing. There would be no feature required to make that work, and no keyword would need to be assigned to access that feature.

And since the module that defined the record can access the fields, you can provide public access by exporting functions from the module. Something with a signature like MyRecord -> TypeOfField to read a field, or { record: MyRecord, value: TypeOfField } -> MyRecord to write one. (As usual, this type signature syntax should not be taken too seriously.)

I see a potential problem though, in how that interacts with linear types. In Rust (which has affine types, but that's close enough), the compiler tracks which fields of a struct have been moved, and might therefore prevent you from moving the struct as a whole. If Crosscut wanted to do something like that, that wouldn't always be available for private fields.

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.