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 10:18:47 +1100
To: "Web APIs WG (public)" <public-webapi@w3.org>
Message-ID: <20080318231846.GA22818@arc.mcc.id.au>

Hi Travis.

Travis Leithead:
> From the spec...
> 
>   4.2.1. Interface object
> 
>   The interface object for a particular interface has an internal
>   [[Prototype]] object whose value is the Object prototype object.
> 
> So, can infer that the interface object (lets use HTMLDocument) *is
> an* Object? Or is it a Function?

I don’t think you can infer either of these.  Whether ‘typeof x’ will
evaluate to "object" or "function", assuming ‘x’ is an object, depends
only on whether the object implements [[Call]].  The spec doesn’t say
anything about [[Call]] on interface objects at the moment, so I think
either would be acceptable.

> ("object" == typeof HTMLDocument) ? "It's an object"
>   : ("function" == typeof HTMLDocument) ? "It's a function"
>   : "What is it?";
> 
> I see that browsers disagree and that FF3 B4 recently changed to be
> 'object'. Leaving Opera in the wrong?

I wouldn’t say Opera is wrong, but there is probably no need to an
interface object to implement [[Call]] anyway.

Do you think the spec should explicitly say that [[Call]] must not be
implemented?  IMO there isn’t much gain from doing that.

Cameron

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au
Received on Tuesday, 18 March 2008 23:19:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 18 March 2008 23:19:51 GMT