Draft of Function.prototype.bind.

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Tue Nov 4 10:43:02 PST 2008


Mark S. Miller wrote:
> 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:
>> Brendan Eich 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.

Sorry, I meant to post that before.

The bug that Brendan and I were referring to was 61911:
<https://bugzilla.mozilla.org/show_bug.cgi?id=61911>

Also see <http://bugs.ecmascript.org/ticket/251>, but the discussion
there appears to be making ES4-specific assumptions. (It is also quite
confused when referring to ES3: Opera and MSIE's behaviour is correct
according to the spec, but that is because they don't have callable
regexps.)

> 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.

I agree; that's the same reasoning I was using.

Note that in the comments of bug 61911, Brendan used the argument that
regexp objects were proposed to be callable in ES4, but that is presumably
back up for discussion in Harmony. I would recommend against it: callable
regexps were a SpiderMonkey extension never adopted by any non-Mozilla
JavaScript implementation AFAIK, and they introduce an irregularity in
the language.

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list