Callable RegExp vs. typeof (was: Re: Draft of Function.prototype.bind.)

Allen Wirfs-Brock Allen.Wirfs-Brock at microsoft.com
Thu Aug 13 14:02:47 PDT 2009


I think an important part of the "may add" allowance that is somewhat implicit that the only changes to the existing spec. that can be made to accommodate such extension is to cause error conditions to no longer be errors.  If your extensions requires/implies other changes to the spec. then it isn't a valid extension but rather a change to the specification.

>-----Original Message-----
>From: es-discuss-bounces at mozilla.org [mailto:es-discuss-
>bounces at mozilla.org] On Behalf Of Brendan Eich
>Sent: Thursday, August 13, 2009 1:44 PM
>To: Juriy Zaytsev
>Cc: es5-discuss at mozilla.org; es-discuss Steen
>Subject: Re: Callable RegExp vs. typeof (was: Re: Draft of
>Function.prototype.bind.)
>
>On Aug 13, 2009, at 1:28 PM, Juriy Zaytsev wrote:
>
>> There was a discussion of this ticket on Hacker News this morning
>> and we had this slight confusion on whether giving RegExp objects a
>> [[Call]] property is permitted by spec
><http://news.ycombinator.com/item?id=760529
>> >. I thought it was, since section 2 clearly states that
>> implementation can introduce its own extensions, but then someone
>> made a point about exact wording in that section and how it seems
>> that implementation can only add properties that spec doesn't
>> mention (i.e. additional ones) and not those that spec mentions
>> (such as [[Call]]) but doesn't specify them on certain objects.
>>
>> Could someone please clarify this?
>
>Good point. I seem to recall that David-Sarah Hopwood made it already,
>but I'm having trouble finding his message right now.
>
>ES3 Chapter 16 says:
>
>"An implementation may provide additional types, values, objects,
>properties, and functions beyond those described in this
>specification. This may cause constructs (such as looking up a
>variable in the global scope) to have implementation-defined behaviour
>instead of throwing an error (such as ReferenceError)."
>
>As the ycombinator thread correspondent says, this is ambiguous: does
>"may provide ... properties ... beyond those described by this
>specification" mean [[Call]] on a native object specified without
>[[Call]] by ES3 is ok? Or does it mean that only properties whose
>identifiers are not defined at all for any object may be added? Or
>should internal properties be excluded in any event?
>
>The practical issue of typeof /a/ == "function" being misleading and
>causing compatibility problems is paramount. Fixing that by ruling
>that extending RegExp to have a [[Call]] internal property violates
>ES3 is plausible in theory, but again in practice hard if enough
>content depends on /a/(s).
>
>/be
>_______________________________________________
>es-discuss mailing list
>es-discuss at mozilla.org
>https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list