Daily Thought - 2024-07-10
< back to listEven 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.