News for hackers. Stuff that matters.
Re:TypeScript 5.2's New Keyword: 'using' by tantalor on Monday June 26, 2023 @10:34AM (#36480144)
Thanks, that's exactly what I was wondering.

What happens if you save a reference to (or return, etc.) the variable you declared with "using"? Then it will end up automatically disposed, but from the programmers point of view it should still be usable (not disposed).

Re:TypeScript 5.2's New Keyword: 'using' by Dylan16807 on Monday June 26, 2023 @02:08PM (#36483420)
> from the programmers point of view it should still be usable (not disposed)

Then that programmer had their hopes too high. The basic "using" keyword is not for variables you want to move between scopes. Javascript doesn't do reference counting.

For saving/returning, you need to use explicit instances of DisposableStack and .move()