W3C home > Mailing lists > Public > public-webapi@w3.org > March 2008

Re: [Bindings] What does typeof return for interface objects?

From: Cameron McCormack <cam@mcc.id.au>
Date: Wed, 19 Mar 2008 17:06:13 +1100
To: "Web APIs WG (public)" <public-webapi@w3.org>
Message-ID: <20080319060612.GB31842@arc.mcc.id.au>

Travis Leithead:
> I can think of some interesting use cases for implementing [[call]]
> on an interface object... I'd prefer to leave it unspecified at best.


> I agree with Hixie on the point of specifying the behavior of typeof,
> and to me typeof HTMLDocument == 'function' makes sense, since I think
> of these as 'constructor objects' (even if they don't allow object
> construction in some cases).

But if you want ‘typeof HTMLDocument == 'function'’, then you would
need to mandate [[Call]] being implemented on the interface object,
since ECMA-262 says that the typeof operator returns 'function' only if
the object implements [[Call]].  And then if you require [[Call]] to be
implemented, then you’d need to say what that function would do.

So really the only options are:

  * don’t say anything about [[Call]], and thus allow typeof to return
    'object' or 'function',

  * mandate that [[Call]] is not implemented, and thus require typeof
    to return 'object', or

  * mandate that [[Call]] is implemented (and then say what calling the
    function should do), thus requiring typeof to return 'function'.

Requiring that [[Call]] be implemented but not saying what its actual
behaviour should be is a bit strange, I think.

Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au
Received on Wednesday, 19 March 2008 06:06:59 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:25 UTC