@wavded yield* is in tail position there, but the expression it exhausts is not -- it's a divergent recursive call. JS is strict ("eager").
-
-
@BrendanEich I must not be understanding TCO here. Would you have a sec to comment on that gist with an proper TCO version? Recur fib gen. -
@wavded yield* is not return -- yield* E evaluates E eagerly, and exhausts it, yielding each value. return E where E is F() can tail-call F. -
@wavded first yield* will, when recursing to gen(), wait for both of its yields.. that's why it's not a single-op in tail pos@brendaneich -
@getify@BrendanEich ok, so is it possible to infinitely recurse in a generator? if you have an example that may help me get it better. -
@brendaneich@wavded it doesn't seem like generators could ever be TCO'd. even one with only a single yield* in final pos is not a return. -
@BrendanEich so yield* X is just a fancy way of exhausting all the yields from another generator (looping) and then continuing on... -
@wavded FWIW, i like to think of yield* as delegating its own iterator control to another generator.@brendaneich -
@BrendanEich@getify background for my questions; generators enable infinite, lazy, sequences - while() yield - wondered about recursion... -
@getify@BrendanEich think I have it, it's like handing off "yields" to another generator, then continuing on? -
@BrendanEich@wavded@getify I wish I could understand this madness :( -
-
@BrendanEich@getify got it now, thanks for your help! I keep on thinking about lazy, infinitely recursive, Haskell-like functions in JS :) -
@wavded "handing off yields to another generator, then waiting for all of them to finish before going on." :)@brendaneich -
@jeffscottward you don't know JS yet. i'm writing some books to help. ;-) -
@getify@BrendanEich I know, I just said that twice already right :) :)
Marc Harter
BrendanEich
getify
JΞFF WAɌƉ