GeneratorFunctionPrototype should probably be a function

André Bargull andre.bargull at udo.edu
Tue Aug 13 09:41:09 PDT 2013


> Hi,
>
> Section 15.19.3.3 of the July 15 draft says:
>
>      Properties of the GeneratorFunction Prototype Object
>
>      The GeneratorFunction prototype object is an ordinary object. It is
>      not a function object and does not have a [[Code]] internal data
>      property or any other of the internal data properties listed in
>      Table 13. In addition to being the value of the prototype property
>      of the %GeneratorFunction% intrinsic and is itself the %Generator%
>      instrinsic.
>
> Seehttp://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.19.3  <http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-15.19.3>  for
> the gnarlies.  To be explicit, we are talking about this object:
>
>    var GeneratorFunctionPrototype = function*(){}.__proto__;
>
> I think this object should be a function and not a normal object.
>
>    1. The spec doesn't specify any other objects for which "x instanceof
>       Function" that aren't functions.

Isn't that just because no other object inherits from the Function 
object in the specification? For example on the user level you can write 
`class MyFunction extends Function {}`, where `MyFunction.prototype 
instanceof Function` yields true, but `typeof MyFunction.prototype` is 
still "object". IIRC Allen even spec'ed GeneratorFunction similar to if 
it was written in the class syntax.


>    2. Function.prototype.toString is the binding for ".toString()" on
>       this object, but it is only applicable to function receivers.

The same restriction also applies to Number, String, Boolean, RegExp and 
Date (or rather to the corresponding prototype objects). So this is not 
a unique behaviour w.r.t. the GeneratorFunction prototype object.



>
> Sending here as I seem to have forgotten my bugzilla password, and the
> mail is taking too long to get here.  Sorry 'bout that.
>
> Regards,
>
> Andy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130813/22287d8b/attachment.html>


More information about the es-discuss mailing list