Callable RegExp vs. typeof (was: Re: Draft of Function.prototype.bind.)
brendan at mozilla.com
Thu Aug 13 10:07:36 PDT 2009
On Nov 4, 2008, at 10:43 AM, David-Sarah Hopwood wrote:
> The bug that Brendan and I were referring to was 61911:
For reference so new readers don't have to look far back in the old
>> On FF3.0.3, a bit of testing reveals that RegExp instances are indeed
>> callable as functions, which presumably means they have an internal
>> property. And they are clearly native objects, not host objects.
>> 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
> back up for discussion in Harmony. I would recommend against it:
Still agreed ;-).
> regexps were a SpiderMonkey extension never adopted by any non-Mozilla
> the language.
Not so. See https://bugs.webkit.org/show_bug.cgi?id=28117 in
particular https://bugs.webkit.org/show_bug.cgi?id=28117#c12 (quoting
Luke Smith's words here):
"I found that /a/("abc") is implemented (inconsistently) in Firefox
3.0, Firefox 3.5, Safari 3.2.1, Safari 4, Opera 9.6.3, Opera 10 beta2,
Chrome 3 beta, and the WebKit nightlies. It is not implemented in IE6,
IE7, IE8, or Chrome 2."
My comment at https://bugs.webkit.org/show_bug.cgi?id=28117#c21 opines
that we may find it hard to remove callability, but it's even harder
to make typeof /a/ return "function".
This is an issue still.
More information about the es5-discuss