[[Class]] and host objects

Brendan Eich brendan at mozilla.com
Tue Feb 10 18:32:09 PST 2009


I don't see why a host object would claim [[Class]] == "Object" -- we  
have custom classes throughout our DOM, so do others, but if you want  
an object whose [[Class]] == "Object", you want an instance of the one  
true native Object constructor.

The issue with host objects wanting to claim [[Class]] == "Function"  
was not from IE or any browser I know of (recall that IE's alert is  
not a function, rather a callable object). The issue may have been a  
misinterpretation of host objects to mean all those not specified in  
ECMA-262, which would seem to require DOM object methods to be host  
objects whose [[Class]] == "Function". But that's not the case. Either  
such methods are callables that do not claim to be functions (typeof  
alert == "object"), or they are in fact native Function instances.

/be

On Feb 10, 2009, at 6:15 PM, Allen Wirfs-Brock wrote:

> >Mark Miller: I like your #2 direction a lot. If it were feasible to  
> require that host objects not even use [[Class]] "Object", I'd be in  
> favor. However, I'm guessing that would differ too greatly from  
> current browser behavior to have a chance.
>
> That’s what I thought until I probed around a few DOM objects in IE  
> and Firefox and didn’t see any [object “Object”]’s.  We probably  
> need the browser experts to tells whether or not it is common  
> practice to use [[Class]]==”Object” for host objects but a casual  
> inspection looked promising.
>
> From: Mark S. Miller [mailto:erights at google.com]
> Sent: Tuesday, February 10, 2009 6:01 PM
> To: Allen Wirfs-Brock
> Cc: Mark Miller; Brendan Eich; es-discuss
> Subject: Re: [[Class]] and host objects
>
> 2009/2/10 Allen Wirfs-Brock <Allen.Wirfs-Brock at microsoft.com>
> Mark Miller said:  We can get the effect of specifying such  
> indistinguishability simply by specifying that host objects may have  
> as their [[Class]] property "Object", or any string not otherwise  
> used by the spec as a [[Class]] value.
>
>
>
> I generally agree, but I have two "what about's" that actually go in  
> different directions from each other.
>
>
>
> #1 What about "Function" in addition to "Object"? It seems  
> reasonable to have host objects that are functions in addition host  
> objects that are objects. (Counter-argument: slippery slope)
>
>
>
> #2 Why allow "Object" for  host objects that are required to conform  
> to the section 15.3 specification for Object. If they are  
> distinguishable from section 15.3 objects they should have  
> [[Class]]=="Object".  An implementation can use "HostObject" or  
> something else. (Counter-argument: Might confuse some programmers???  
> (seems weak))
>
>
>
> I like your #2 direction a lot. If it were feasible to require that  
> host objects not even use [[Class]] "Object", I'd be in favor.  
> However, I'm guessing that would differ too greatly from current  
> browser behavior to have a chance.
>
>
>
> -- 
>    Cheers,
>    --MarkM

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090210/211ef5bb/attachment.html>


More information about the Es-discuss mailing list