2 ms·
Furthermore, it's not clear that this can really be implemented in a reasonable way Which is why RAII in a language without exceptions is inappropriate for a r
by Animats 8y ago
Furthermore, it's not clear that this can really be implemented in a reasonable way
Which is why RAII in a language without exceptions is inappropriate for a resource which has a status on closeout.
- pcwalton 8y agoThe alternative to closing the file in the destructor is leaking OS resources in the event of unexpected control flow destroying the file object. I fail to see how that is preferable.
- masklinn 8y agoA linear resource would require that the resource is explicitly released on all codepaths no?
- pcwalton 8y agoNot in Rust, and not in any language where you can put resources in objects with shared ownership (i.e. any remotely popular general purpose language). Throwing exceptions isn't a particularly good solution either, for the same reason. Exceptions are hard to reliably handle when you can't easily reason about where they will be thrown from.