On Oct 10, 2011, at 1:41 PM, Bob Nystrom wrote: > On Mon, Oct 10, 2011 at 1:33 PM, Dean Landolt <d...@deanlandolt.com> wrote: > > Here's an example: > > let tree = [['a', 'b', 'c'], [['d', 'e'], 'f'], ['g']]; > > let inOrder = walk(tree); > for (node of walk(tree)) alert(node); // a, b, c, d, ... > > walk(tree) { > if (typeof tree == 'string') { > yield tree; // leaf > } else { > yield* walk(tree); // branch > } > } > > What would the above look like without generators? > > > Woah there -- where does this syntax come from? Was `walk(tree) {...}` > supposed to be `function* walk(tree) {...}` instead? Or is this intended to > represent some sort of method generator? If the latter, doesn't this need > some mechanism to distinguish it from a non-generator method? > > Whoops, my mistake. Too much time working on the class proposal where > "function" isn't needed for methods.
I spy a Dart ;-). > Yes, that should be function*. Still a great delegated generator example. Thanks, /be
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss