Daily Note - 2024-07-10
Hey, I'm Hanno! These are my daily notes on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!
This note was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.
Even if you have a linear type system, that doesn't mean every type needs to be linear. It's totally fine to also have types whose values can be copied implicitly (i.e. used multiple times), or dropped implicitly (i.e. used zero times).
Something like this is implemented in Rust, which has affine types by default (used at most once; i.e. they are moved, not
copied). But you can derive
Copy
for a type, meaning values of that
type get copied implicitly. That allows you to use them
more than once, which makes the type no longer affine.
In a similar vein, types in Caterpillar could be linear
by default, but then be marked as AutoCopy
(for types you might want to use more than once) or
AutoDrop
(for types you might want to use
zero times). And this is a totally reasonable thing to
do, for example for pure values like numbers or vectors.