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

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

From: Travis Leithead <travil@windows.microsoft.com>
Date: Tue, 18 Mar 2008 20:25:11 -0700
To: Cameron McCormack <cam@mcc.id.au>, "Web APIs WG (public)" <public-webapi@w3.org>
Message-ID: <937543397460F840810FA27D2922880F5BC923D280@NA-EXMSG-W602.wingroup.windeploy.ntdev.microsoft.com>
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).

-----Original Message-----
From: public-webapi-request@w3.org [mailto:public-webapi-request@w3.org] On Behalf Of Cameron McCormack
Sent: Tuesday, March 18, 2008 4:19 PM
To: Web APIs WG (public)
Subject: Re: [Bindings] What does typeof return for interface objects?

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 McCormack, http://mcc.id.au/

        xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au

Received on Wednesday, 19 March 2008 03:25:52 UTC

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