One of the awkward things about actual linear types is specification of cleanups...
zwarich @zwarich@hachyderm.io
One of the awkward things about actual linear types is specification of cleanups. In many contexts, you'd like to describe the required cleanup if you're leaving a block for any reason. However, with linear types you might end up with something like this:
let x = make_linear()
defer {
free(x)
}
let (x, result1) = modify_and_compute_result(x)
<code that may cause an early return>
let (x, result2) =
modify_and_compute_other_result(x)
return result1 + result2
If you're just rebinding `x`, then the binding captured by the `defer` block is not the same at every point that may require a cleanup. One obvious solution is to allow for actual reassignment of the variable if it is consumed on the RHS, e.g.
(x, let result1) = modify_and_compute_result(x)
Are there any other good solutions to this problem?