|
|
|
|
|
by millstone
3331 days ago
|
|
You would be required to drop values that aren't moved elsewhere. Currently Rust has a one-bit reference count which dynamically tracks which values need to be dropped. Linear types would transform this into a static property that the compiler checks. Part of the pain would come from conditionals: if something {
func(val1);
} else {
func(val2);
}
This would be disallowed because the liveness of val1 and val2 can't be statically known after the conditional. |
|
This is indeed "pain", but of a good kind (at least it if the error message is decent).
I admit there are harder cases:
Is correct, if strange, code which I assume is hard for a compiler to understand. But then it is hard for humans too.