2 ms·
It's not really like RAII either, because you have to `using` the object. It's a closer cousin of Python's context manager (aka C#'s using statement — probably
by masklinn 3y ago
It's not really like RAII either, because you have to `using` the object.
It's a closer cousin of Python's context manager (aka C#'s using statement — probably where it actually comes from — and Java's try-with-resource), which probably hew closer to Common Lisp's unwind-protect (that is not type-oriented, but usually you'd create your own macro around that).
- iainmerrick 3y agoYou’re right, but I don’t see a big difference in practice if the compiler is able to check that you’re using “using” correctly! Hopefully there’s at least a warning if you call something that returns a disposable object, but don’t dispose of it.