Questions/issues regarding generators

Allen Wirfs-Brock allen at
Fri Mar 29 18:21:07 PDT 2013

On Mar 7, 2013, at 11:05 AM, Andreas Rossberg wrote:

> On 7 March 2013 18:30, Allen Wirfs-Brock <allen at> wrote:
>> On Mar 7, 2013, at 7:37 AM, Andreas Rossberg wrote:
>>> 1) Are the methods of a generator object installed as frozen
>>> properties? (I hope so, otherwise it would be more difficult to
>>> aggressively optimise generators.)
>> We discussed the factoring of the generator objects at the Nov 27 meeting.
>> there is a
>> sketch of the hierarchy we agreed to in in the notes
>> TThe design I presented at the meeting is very close to that final one,
>> answers this question, and is easier to read:
> Ah, thanks. It seems that I missed that part of the meeting. I'll have a look.

I created a more readable class hierarchy diagram based on the  above photo from the Nov. meeting.  This is what I'm using as my guide for putting generators into the spec. draft. 
The diagram is at 

The most significant change from the meeting (and it really wasn't explicit on the whiteboard) is that generator prototypes don't have a "constructor" property that links back to its generator function instance.  In other words, you can't say:

function * ofCollection() {for (i of collection) yield i};
var itr1 = ofCollection();
var itr2 = iter1.constructor();  //TypeError

Allowing such constructor access seems like an unnecessary (and possibly undesireable) capability when you just passing generator instances around to be used as iterators.  Anybody disagree?

itr1 instanceof ofCollection

still works (subject to the usual instanceof caveats)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list