On May 10, 2012, at 22:13 , Brendan Eich wrote:

> What are iterFunc and iterGen?

I fixed the code, see below.

> The * means to exhaust the yield operand's value, otherwise you're just 
> yielding that value. PEP-380 is the basis:
> 
> "The following new expression syntax will be allowed in the body of a 
> generator:
> 
> yield from<expr>
> 
> where <expr> is an expression evaluating to an iterable, from which an 
> iterator is extracted. The iterator is run to exhaustion, during which time 
> it yields and receives values directly to or from the caller of the generator 
> containing the yield from expression (the "delegating generator")."
> 
> 
> There's no point requiring an iterator not an iterable given the special 
> form. Are you actually concerned about the * being too little syntax for the 
> special form's semantics?

I just like the idea of seeing where recursion recursion happens and that 
generator recursion looks similar to function recursion. More a coding style 
thing than about ES.next syntax or semantics.

>>     function visit(visitor) {
>>         if (this.left) {
>>              visit(this.left, visitor);
>>         }
>>         visitor(this.label);
>>         if (this.right) {
>>              visit(this.right, visitor);
>>         }
>>     }
>> 
>>     function* iter() {
>>         if (this.left) {
>>             yield* iter(this.left);
>>         }
>>         yield this.label;
>>         if (this.right) {
>>             yield* iter(this.right);
>>         }
>>     }
>> 
>>     Tree.prototype.visit = visit;
>>     Tree.prototype[iterator] = iter;
> 

-- 
Dr. Axel Rauschmayer
[email protected]

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

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

Reply via email to