Resource management

Ron Buckton Ron.Buckton at
Sun Jan 1 01:19:22 UTC 2017

> -----Original Message-----
> From: es-discuss [mailto:es-discuss-bounces at] On Behalf Of Isiah
> Meadows
> Sent: Saturday, December 31, 2016 8:34 AM
> To: J Decker <d3ck0r at>
> Cc: Raul-Sebastian Mihăilă <raul.mihaila at>; es-discuss <es-
> discuss at>
> Subject: Re: Resource management
> Not enough. Not looking for an `await` replacement, but something closer to
> Python's `with` statement or Java's `try`-with-resources.
> Or, if you want something
> Python:
> example%2F&
> 4f8a4e3489b608d4319ad95d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7
> C0%7C636187988525799540&sdata=BbbqX753QBWZaGwXqqmdWbX7sOvdp
> 3VADi%2FLjqpf2%2Fs%3D&reserved=0
> Java:
> lose.html&
> a4e3489b608d4319ad95d%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0
> %7C636187988525799540&sdata=wVj3VjrOri80tOmnK%2Bvyoe2e7rb2Ft%2B
> wHv%2BkjOk%2FsFQ%3D&reserved=0
> JavaScript's idioms tend towards Python, Java, C#, etc. in how resources are
> handled, so things like Ruby's `begin`-`ensure` wouldn't work as well (that
> was where I got my generator workaround from, actually, and as you can
> see, it's not exactly very obvious).
> -----
> Isiah Meadows
> me at

Speaking of C#, the C# variant of this is the `using` statement:

I'm not advocating `using` as a new keyword for ES, given it's not already reserved and would have ASI hazards. The Java "try-with-resources" seems to be a fairly flexible syntax, though its adoption in ES would be predicated on some well-defined heuristic for determining which method to be used, given that ES does not have interfaces (and thus no System.IDisposable or java.lang.AutoCloseable). That would likely be an existing method name, such as "return" as used in iterators today, or a built-in Symbol which could be retrofit onto %IteratorPrototype%.


More information about the es-discuss mailing list