Re: [whatwg/webidl] Add a `disposer` keyword for disposal methods (Issue #1459)

jasnell left a comment (whatwg/webidl#1459)

> Why not have a single keyword...

That works for me also. I'm less concerned with the specific syntax than I am with having *an* ability to declare that an object is disposable.

I think that maybe the one other place this specific proposal probably breaks down is that it assumes the disposer method is based around a public API, at least as shown in the examples above. This might not be the case and the only disposer method exposed  might be the `Symbol.dispose` and `Symbol.asyncDispose` properties. So, perhaps instead of marking a specific method as the disposer -- or in addition to it -- we should have a standalone `disposable;` attribute... e.g.

```
interface Foo {
  disposer;  // Means that there is a [Symbol.dispose] property on the interface
  async_disposer;  // Means that there is a [Symbol.asyncDispose] property on the interface
}

interface Bar {
  disposer undefined close();  // Means that the close method is also exposed as [Symbol.dispose]
  async_disposer Promise<undefined> asyncClose(); // Means that the asyncClose() method is exposed as [Symbol.asyncDispose]
}
```

Makes things a bit more complicated, of course, so I'm not sure if this is the right way to go or not, but if there is no otherwise exposed method to annotate (as in the `Foo` example above) then `async_disposer` would be necessary to differentiate.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1459#issuecomment-2891272575
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1459/2891272575@github.com>

Received on Monday, 19 May 2025 14:35:37 UTC