4 ms·
> 2. we have seeked in a file that was already closed. > The second error, however, is much harder to catch. Most programming languages support the necessary f
by amedvednikov 7y ago
> 2. we have seeked in a file that was already closed.
> The second error, however, is much harder to catch. Most programming languages support the necessary features to make this error hard, typically by closing the file upon destruction or at the end of a higher-order function call, but the only non-academic language that I know of that can actually entirely prevent that error is Rust.
Why not simply add an `is_closed` flag and throw an error if it is?
- msl 7y ago> Why not simply add an `is_closed` flag and throw an error if it is? That's a way of doing it at runtime. The article describes catching the error at compile time.
- amedvednikov 7y agoI see, thanks.
- aliceryhl 7y agoThe compiler is not able to catch that, and that the compiler can catch it is the whole idea behind type states.