Suggestion: add using
fields to classes that are auto-disposed on @@dispose
#250
Open
Description
The idea is that this...
class C {
using a = foo();
using #b = bar();
await using c = baz();
await using #d = thing();
}
...is sugar for (roughly) this:
class C {
a = foo();
#b = bar();
c = baz();
#d = thing();
[Symbol.dispose]() {
try {
this.a[Symbol.dispose]()
} finally {
this.#b[Symbol.dispose]()
}
}
async [Symbol.asyncDispose]() {
try {
await this.c[Symbol.asyncDispose]()
} finally {
await this.#d[Symbol.asyncDispose]()
}
}
}
It'd make collections of named disposable things a lot easier to work with.
Obviously intended as a follow-on proposal, so feel free to label accordingly.
Metadata
Assignees
Labels
No labels
Activity