[whatwg/webidl] Allow dictionaries and callbacks to be distinguishable (Issue #1191)

https://webidl.spec.whatwg.org/#dfn-distinguishable

It isn't clear to me why callbacks and dictionaries can't be distinguished.

I'm designing an API like:

```js
whatever(callback);
```

But there's a strong possibility that options will be added in future, and I want to avoid this pattern:

```js
whatever(() => {
  // Quite
  // a
  // bit
  // of
  // code
}, { behaveDifferently: true });
```

And instead go for:

```js
whatever({
  behaveDifferently: true,
  callback() {
    // Quite
    // a
    // bit
    // of
    // code
  }
});
```

But it seems like I can't overload from `whatever(callback)` to `whatever({ callback })`.

I would have assumed that an argument could be treated as a callback if it's callable.

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

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

Received on Friday, 16 September 2022 17:27:07 UTC