Should host objects be able to have [[Class]] "Function", "Array" etc.?
mjs at apple.com
Wed Nov 19 08:08:39 PST 2008
On Nov 18, 2008, at 11:00 AM, Mark S. Miller wrote:
> On Tue, Nov 18, 2008 at 3:32 AM, Maciej Stachowiak <mjs at apple.com>
> Host functions in the DOM do not generally have a "prototype"
> property, because they generally cannot be invoked as constructors.
> However, I think all functions that operate on functions should
> accept these native functions. I think this is best dealt with by
> making the bind algorithm more generic.
> More generic than the one in the Kona draft? How? As written, it
> will curry anything with a [[Call]] property. It conditions whether
> to use the 'prototype' and 'length' properties of the original based
> on whether the original's [[Class]] is "Function". And it will curry
> the original's [[Construct]] property only if the original has a
> [[Construct]] property. I had hoped we could agree to make it less
> generic -- all these conditionals are troublesome. But how would you
> make it more generic?
If the current version doesn't assume anything about the possible
value and attributes of the "prototype" property then that shouldn't
be a problem.
> 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". Why should Math.random be
required to have [[Class]] "Function", but document.getElementById or
Math.myImplementationExtension be required not to? Do you really think
it makes sense to determine whether something is a function by whether
it is mentioned in the ECMAScript spec?
(Note also that Math.random has [[Class]] "Function" but not a
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Es-discuss