On Aug 13, 2013, at 9:41 AM, André Bargull wrote:

>> 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.
>> 
>> See http://people.mozilla.org/~jorendorff/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. 
> 

More generally, we've previously discussed and decided to break from the ES<6 
convention that built-in prototype objects act as if they were instances of 
their associated constructors.  That generally won't be the case for prototypes 
defined using a class declarations.  We even decided to relax that requirement 
for the existing built-in, except where it would create backwards compat issues 
(Function.prototype and Array.prototype appear to be situations where there are 
such issues.)

instanceof is essentially broken when applied to most non-built-in prototype 
objects because they usually just aren't defined to proper operate as instances 
of the associated constructor.

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

same basic issue, many own or inherited prototype methods won't work on 
prototype objects.

Allen


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to