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

Maciej Stachowiak mjs at
Thu Nov 20 01:26:34 PST 2008

On Nov 20, 2008, at 12:24 AM, David-Sarah Hopwood wrote:

> Maciej Stachowiak wrote:
>> On Nov 19, 2008, at 11:37 PM, David-Sarah Hopwood wrote:
>>> Maciej Stachowiak wrote:
>>>> On Nov 18, 2008, at 11:00 AM, Mark S. Miller wrote:
>>>>> I also don't see a problem with David-Sarah's suggestion of  
>>>>> forbidding
>>>>> host objects from having [[Class]] "Function". Most places in  
>>>>> the spec
>>>>> care only about whether something is callable (has a [[Call]]
>>>>> property), not whether it has [[Class]] "Function".
>>>> It seems arbitrary to me that functions implemented in native code
>>>> ("internal functions" in ECMA-262 terms)
> There's no such thing as an "internal function", in ECMA-262 terms.
> You presumably meant "callable host objects" here.

No. See "10.1.1 Function Objects" in ECMA-262 3rd edition.

"Internal functions are built-in objects of the language, such as  
parseInt and Math.exp. An implementation may also provide  
implementation-dependent internal functions that are not described in  
this specification."

>>>> that are part of the ECMAScript
>>>> spec must have the [[Class]] "Function", but any that are not  
>>>> specified
>>>> there (and are perhaps specified elsewhere) would be required not  
>>>> to
>>>> have [[Class]] "Function".
>>> It is perfectly possible for a function specified elsewhere to be
>>> a native Function object (and to have whatever other methods and
>>> properties that 'elsewhere' specifies for it). There is little  
>>> reason
>>> to define callable non-functions, since functions are flexible  
>>> enough.
>> At least by the definitions of Host object, Native object and Built- 
>> in
>> object, any object "supplied by the host environment" rather than "
>> supplied by an ECMAScript implementation, independent of the host
>> environment" is a Host object.
> You're misreading this. Any object provided by a host API (such as the
> DOM in browsers) can be a native object. It would be ridiculous not to
> allow that: what advantage would there be in prohibiting a DOM
> implementation or other API from being written partly in ECMAScript,
> or behaving *exactly* as if it were partly written in ECMAScript?

However, "internal functions" do not behave exactly as if they were  
written in ECMAScript. That is exactly the point of the concept.

At this point I will concede it is unclear whether an internal  
function that is part of a host API is a native or host object. But I  
am pretty sure they have just as much right to have [[Class]]  
"Function" as Math.random.


More information about the Es-discuss mailing list