3 ms·
`with-file` doesn't guarantee anything about users who forget to use it. With RAII, only the implementor needs to remember to use it, users can't “forget”, beca
by catnaroek 10y ago
`with-file` doesn't guarantee anything about users who forget to use it. With RAII, only the implementor needs to remember to use it, users can't “forget”, because there's nothing to remember.
> It's perfectly possible to do the same thing in a higher-level language though - if you only expose with-file then you have the same safety guarantees as RAII.
It's still less sophisticated than desirable. In Rust, objects can be moved to a different environment, so cleanup need not follow a strict LIFO discipline.