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

Maciej Stachowiak mjs at apple.com
Fri Nov 14 20:25:07 PST 2008


On Nov 14, 2008, at 4:48 PM, David-Sarah Hopwood wrote:

> David-Sarah Hopwood wrote:
>> Waldemar Horwat wrote:
>>> Mark S. Miller wrote:
>> [Kona 15.3.4.5]
>>>>        11. If the [[Class]] property of /G/ is *"Function"*, then
>>>>               1. Get the *length* property of /G/.
>>>>               2. Let /L/ be Result(11a) minus the length of /A/.
>>
>> [These substeps are actually labelled a. and b.]
>>
>>> What does "minus" mean here?  Result(11a) could be anything.
>>
>> The 'length' property of a built-in object with [[Class]] "Function"
>> is not Writable or Configurable [Kona 15.3.5.1], so it must be equal
>> to the number it was set to in either [Kona 13.2 step 7] or
>> [Kona 15.3.4.5 step 11c or 12], which are the only places where
>> built-in objects of [[Class]] "Function" are created (and [[Class]]
>> cannot be changed after creation). But that should be explained in a
>> NOTE section.
>>
>> 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.
>
> 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.

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

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.

Regards,
Maciej



More information about the Es-discuss mailing list