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

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.

OK.

> 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