2009/5/14 Brendan Eich <[email protected]>: > function gen(arg) { > foo((lambda (x) yield x), arg); > } > function foo(callback, arg) { > try { > callback(arg); > } finally { > alert("I'm ok!"); > } > } > g = gen(42); > print(g.next()); // tell the user the meaning of life, etc. > g = null; > gc(); > > I think finally is the only issue, since how else can you tell that foo > didn't see a return or exception from the callback? > > It's true that this finally-may-not-run wrinkle is confined to generator > functions in JS1.7, i.e., without lambda.
lambda can be combined with the generators if the yield semantic would be altered to execute any finally block it resides in in the same way the return does. Then in the above example the alert would be executed when the lambda does yield. This is how continuations in Rhino works with any continuation long jump respecting lexical finally blocks. Igor _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

