Resource management (eg. try-with-resources)

Michał Wadas michalwadas at
Fri Nov 10 15:00:32 UTC 2017

After I started writing code  extensively using async-await I have noticed
that I would like to have automated way of dealing with resource management.

Scope-level manage was proven (Python, C++, Java at least) to be intuitive
and error proof.

Previous discussion on this topic: https://esdiscuss.

Example syntax:

try with Expression as Identifier {

} catch... finally... and Symbol.close methods would be called respectively on
entering and leaving try block.

Plays well with both synchronous and asynchronous resource access.

Another option is to reuse with:

with(expression as identifier) {


Though it would be confusing to statement with wildly different semantics
in strict mode.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list