using Private name objects for declarative property definition.

Allen Wirfs-Brock allen at
Mon Jul 11 09:25:23 PDT 2011

On Jul 10, 2011, at 6:58 PM, Brendan Eich wrote:

> On Jul 10, 2011, at 10:54 AM, Allen Wirfs-Brock wrote:
>> Why not a non-writable,non-enumerable non-configurable data property on Function.prototype.
> We're talking about isGenerator, right? There is no Generator constructor, no shadowing opportunity. Function can create a generator if yield occurs in the body string.

Oops, forgot we were talking about isGenerator.  So why not internally defined

const  __generatorProto__ = Object.create(Function.prototype, {isGenerator: {value: true}});

and specify that function containing yield are created as if by:
     __generatorProto__ <| function (...) {...yield...}

 In other words, generator functions have a different [[Prototype]] than regulator functions.

Alternatively, isGenerator could be a method, but that's the the point here.


More information about the es-discuss mailing list