Daily Thought - 2025-03-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!
I think that I've come up with a design for data types that is simple, orthogonal, and composable. Let's get into it, starting with records:
record { value: Integer, unit: Text }
A record has multiple fields, each of which has a name and a type. It's a composite (or compound) data type, meaning it's a single value that bundles multiple other values together. This kind of thing is often called "struct", "class", or "object" in various languages. In terms of programming language theory, this is called a product type.
I like the name "record" (inspired by Pascal), because it's easy to understand, and doesn't seem to come with a lot of baggage. "Class" or "object" come from the object-oriented world, which would be misleading. "Struct" would be familiar to many, but as a name it seems overly broad. (Many data types could be "structures", I think?)
Records are (by default; I'll expand on that later) structurally typed and anonymous. You could assign a name to a record by returning it from a module, for example, and refer to that name from elsewhere. Or you could define a record directly in those places, anonymously.
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.