Should host objects be able to have [[Class]] "Function", "Array" etc.?

David-Sarah Hopwood david.hopwood at
Mon Nov 17 21:24:55 PST 2008

Maciej Stachowiak wrote:
> On Nov 14, 2008, at 4:48 PM, David-Sarah Hopwood wrote:
>> David-Sarah Hopwood wrote:
>>> Caveat:
>>> [section 15]
>>> # The value of the [[Class]] property of a host object may be any value,
>>> # even a value used by a built-in object for its [[Class]] property.
>>> So any random host object might have [[Class]] "Function" (which is a
>>> bug). If that is the case, all bets are off (and in that case steps 11
>>> and 15 of the 'bind' algorithm are broken anyway -- for example, the
>>> 'length' or 'prototype' properties of G might not exist).
>> We didn't resolve this.

We still didn't resolve this.

If it is not fixed by requiring host objects not to have [[Class]]
"Function", then the bind algorithm must be fixed in some other way.
So must all of the other bugs in ES3 that result from assumptions
about objects with [[Class]] "Date" or "RegExp" having all of the
properties and behaviour of those types, in sections 15.5.4.{10,11,12,14},
and in the specifications of Date and RegExp methods.

>> Should host objects be required not to have [[Class]] "Function"?
> No, I do not think this is a sounds requirement. All native functions in
> the DOM are host objects, and I think it would be wrong to disallow them
> to have [[Class]] "Function", or to prevent any Function.prototype
> methods from working on them.
> I would find it acceptable to require any host object that has [[Class]]
> "Function" to implement the [[Call]] internal property and to have a
> read-only non-deletable property named "length" which has a numeric value.

The "prototype" property is also used. I haven't checked what is assumed
about it.

>> Should host objects be required not to have [[Class]] "Array",
>> "Boolean", "Date", "Decimal", "JSON", "Math", "Number", "RegExp",
>> or "String"?

In fact [[Class]] is only checked for the values "Function", "Date"
and "RegExp", so it would be sufficient to disallow those values for
the [[Class]] of a host object. (OTOH, allowing the other values in the
list is not necessary, since the only effect would be on the default
implementation of toString(), which could be overridden anyway.)

Note that this means that the comments about host objects emulating
arrays were not relevant; they would still be able to with this

> I disagree with this requirement as well. For weird web compatibility
> reasons, WebKit has a host class that is identical to the native String
> class in every way, except that it compares equal to null and undefined,
> vended in rare circumstances. I don't think this hurts soundness of the
> language and I see no reason to forbid it.

We've now established that this argument is also not relevant to the
question about [[Class]], since having one of the above list of
[[Class]]es would not help to make either WebKit's string-like
host object or SpiderMonkey's document.all conformant.

David-Sarah Hopwood

More information about the Es-discuss mailing list