Draft of Function.prototype.bind.

Mark S. Miller erights at google.com
Mon Nov 3 20:51:42 PST 2008

On Mon, Nov 3, 2008 at 7:08 PM, Brendan Eich <brendan at mozilla.com> wrote:
> See also 11.4.3 The typeof Operator (second to last table row).

For reference, the last three rows of that table are

Object (native and doesn't implement [[Call]]) "object"
Object (native and implements [[Call]])        "function"
Object (host)                                  Implementation-dependent

So it's pretty clear from the text you cite that typeof of a native object
that implements [[Call]] must be "function".

On Mon, Nov 3, 2008 at 8:14 PM, David-Sarah Hopwood <
david.hopwood at industrial-designers.co.uk> wrote:

> > There is evidence for this, because Mozilla's regexps used to report
> > typeof-type "function" and so fell into logic wanting only a function,
> > not a callable host object.
> The resolution of that bug is clearly nonformant to ES3 section 11.4.3,
> as at least two commenters ('Ish' and Garrett Smith) pointed out.

Can someone provide a link to this bug, or to that prior discussion of this
bug? Thanks.

On FF3.0.3, a bit of testing reveals that RegExp instances are indeed
callable as functions, which presumably means they have an internal [[Call]]
property. And they are clearly native objects, not host objects. However,
unlike Rhino or WebKit, of FF3.0.3 at least, typeof of a RegExp does return
"object". I don't see any way to rationalize this as conforming to the spec.
Since WebKit conforms to the ES3 spec in this regard, it would seem that one
can both follow this clause of the spec and not break the web.

On Mon, Nov 3, 2008 at 8:16 PM, Maciej Stachowiak <mjs at apple.com> wrote:

> It's saying you can call anything that's callable a function, or perhaps
> even loosely defining a term "function".
> But this does not guarantee that typeof returns "function", that the
> internal [[Class]] property has the value "Function", or that
> Function.prototype is in the prototype chain, among other potentially useful
> properties.

If F is a callable native object, then the section of the spec Brendan cites
(and which FF violates) does guarantee that |typeof F| be "function".
Whether we want to describe such objects as functions in prose about them is
another matter. In descriptive prose, I prefer to describe as functions only
native objects whose [[Class]] property is "Function".

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20081103/20508125/attachment.html>

More information about the Es-discuss mailing list