Re: [heycam/webidl] Define that interface objects are constructors (#698)

FWIW, it seems there’s a number of ways to observe this distinction beyond just Proxy — pretty much anywhere IsConstructor is used, I guess. In addition to peeking out through various programmatic APIs, it can also impact evaluation of ‘bare’ syntax (third example below). Each of the following statements will throw a TypeError if `Foo[[Construct]]` is absent, but will not throw if it’s present:

```js
Reflect.construct(Bar, [], Foo);

customElements.define('x-x', Foo);

class Bar extends Foo {}
```

Usually it’s throw vs don’t throw, but sometimes neither throws and they just do other different things:

```js
// If Foo[[Construct]] is present, returns new Foo.
// If Foo[[Construct]] is absent, returns new Array.
Array.from.call(Foo, []);
```

> I think it'd be very strange to have callable interface objects exist at all, and be reachable via the .constructor property, if they are not also [[Construct]]able.

I agree.

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

Received on Thursday, 3 October 2019 06:19:54 UTC