3 ms·
> 1. Does that solve the close problem as well as linear types? No. > 2. Do linear types solve other problems that the above doesn't? Yes: destructors which
by masklinn 4y ago
> 1. Does that solve the close problem as well as linear types?
No.
> 2. Do linear types solve other problems that the above doesn't?
Yes: destructors which can fail. This is an issue in C++ and Rust. For instance, in most OS closing a file may return an error. With an implicit closure, that is not an information you can retrieve, you have to know that an error can occur, figure out that you might be interested, and add non-standard handling for it (since the standard is to just drop the value).
With linear types, the "close file" function you had to invoke will also return an error you have to handle.
This is a problem with many resource types (though maybe not all).