Earlier quoted context omitted.
You want to force an extra layer of indentation for every Box or Vec you create, and leak memory if you forget to write "with"? No thank you! No, no, Python like with clauses, for opening files and such.
RAII (i.e. destructors that automatically run on values when leaving a scope) is what lets one avoid manually freeing Box and Vec, so you want to split the world into "destructor resources" (RAII) and "with resources", maybe with some guidelines for when to choose which. Presumably a data type that contains a "with resource" would itself have to be a "with resource" (or else why bother?). This makes "with"-ness abstr…
On languages that support currying, or leaving the last parameter out of the call if it is a lambda, you can create high-order-functions for resource management.
The effort is no different than implementing RAII classes.
withDBConnection {
r = db.execute ("SELECT....")
}
Here the function withDBConnection calls the lambda, providing it an implicit parameter for the db connection, which it fully controls.There are more fancy ways to improve on this, specially if the language also allows for macros.
So I find a bit sad, that the discussions of with/using/try don't focus on the FP way of doing resource management.