Ron.Buckton at microsoft.com
Sun Jan 1 01:19:22 UTC 2017
> -----Original Message-----
> From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Isiah
> Sent: Saturday, December 31, 2016 8:34 AM
> To: J Decker <d3ck0r at gmail.com>
> Cc: Raul-Sebastian Mihăilă <raul.mihaila at gmail.com>; es-discuss <es-
> discuss at mozilla.org>
> 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
> 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 isiahmeadows.com
Speaking of C#, the C# variant of this is the `using` statement: https://msdn.microsoft.com/en-us/library/yh598w02.aspx
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