News for hackers. Stuff that matters.
Re:TypeScript 5.2's New Keyword: 'using' by robby_w_g on Monday June 19, 2023 @11:46AM (#36392414)
The proposal[1] explains several cases where try…finally is verbose or even can result in subtle errors. The upshot for me is that this feature adds RAII to JavaScript. It makes resource management convenient and more maintainable. Seems like a no brainer to me.

[1] https://github.com/tc39/proposal-explicit-resource-managemen...

Re:TypeScript 5.2's New Keyword: 'using' by DougBTX on Monday June 19, 2023 @12:16PM (#36392789)
> The upshot for me is that this feature adds RAII to JavaScript

That doesn’t appear to be the case, a resource can be returned, but this is block scoped. It appears to be closer to a using statement in C#.

Re:TypeScript 5.2's New Keyword: 'using' by TJSomething on Monday June 19, 2023 @01:17PM (#36393737)
Based on my reading of the spec, you can't actually return a resource, since the disposal semantics need to map exactly to calling [Symbol.dispose] in a finally block at the end of the current block. Also, unlike C#, you can have multiple using statements in the same block, which will be disposed of in LIFO order.
Re:TypeScript 5.2's New Keyword: 'using' by monkpit on Monday June 19, 2023 @07:29PM (#36397755)
You can create a resource without “using” it immediately, though.
Re:TypeScript 5.2's New Keyword: 'using' by moron4hire on Monday June 19, 2023 @07:43PM (#36397853)
You can have multiple using statements over the same block in C#.