3 ms·
1. Scope exit. 2. Const. 3. On declaration. 4. I don't know what "chained resource" means. If you mean multiple declarations within the same scope, they all
by bakkoting 3y ago
1. Scope exit.
2. Const.
3. On declaration.
4. I don't know what "chained resource" means. If you mean multiple declarations within the same scope, they all get disposed, in LIFO order (even if disposing one of them throws).
5. An error when the `using` statement runs. (Unless the RHS itself is null, rather than an object without a `Symbol.dispose` method; this lets you have conditional declarations.)
- seniorsassycat 3y ago4 I mean `using x = a(b(), c())` if all functions return a disposable value will all three be disposed, or only the value returned by a and assigned to x?
- bakkoting 3y agoOnly the value assigned to x.
- seniorsassycat 3y ago5 is an interesting choice, what is the downside to allowing `using` on non-disposable values, treating it like a no op disposer? Otherwise a function that takes a maybe-disposable object parameter has to check if the symbol is defined, or the caller has to wrap the non disposable object
- bakkoting 3y agoBecause it's usually an error, and the benefit of catching the error cases outweighs the cost of losing that flexibility.
- seniorsassycat 3y agoWould be nice to include `guaranteeDisposable(x)` in the spec for cases you want to handle non-disposable values