5 ms·
Sadly it needs a language feature that doesn't exist yet
by n2d4 2y ago
Sadly it needs a language feature that doesn't exist yet
- wruza 2y agos/yet/thankfully/. We don’t need it cause it solves no real problem and the solution is loaded with implicit complexity.
- unilynx 2y ago'using' fixes having to do cleanup in a finally {} handler, which you can a) forget, and b) often messes up scoping of variables as you need to move them outside the 'try' block.
- wruza 2y agoIt also creates additional finalization semantics for a using-ed value. Which has all sorts of implications. lock.do(async (lock) => {work}) is a similar construct - a scope-limited aquisition that requires nothing special. Catch/finally not sharing a scope with try is a repeated mistake, that I surely agree with!
- sureIy 2y agoWhat do you mean? You can definitely already wrap that into a Symbol.dispose-keyed object and use it via `using`
- n2d4 2y ago`using` is not a thing in JS
- sureIy 2y agoUh, you are wrong. It absolutely is a thing and it has been in your browser and Node for longer than a year. https://github.com/nodejs/node/pull/48518 https://github.com/nodejs/node/pull/48518 https://github.com/tc39/proposal-explicit-resource-management https://github.com/tc39/proposal-explicit-resource-managemen...