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

Maciej Stachowiak mjs at
Wed Nov 19 23:46:31 PST 2008

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) 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. It's true that this is a vague  
criterion, and an implementation could call anything it wants a native  
object instead of a host object by creatively interpreting what is  
part of the "ECMAScript implementation" and what is the "host  
environment". But arguably such a loophole would make any requirement  
on the [[Class]] value of host objects pretty weak, since native  
objects could still do whatever they want.

I think what we really want for [[Class]] "Function" is a particular  
interface (callable and perhaps has a read-only "length" property with  
integer numeric value), not any rule based on whether the object is  
native or host.


More information about the Es-discuss mailing list