How would shallow generators compose with lambda?

Waldemar Horwat waldemar at
Thu May 14 13:47:16 PDT 2009

This whole thing is another nail in the coffin of generators.  Generators are the root of the troublesome longjmp's which don't play well with others.


Brendan Eich wrote:
> To make this clear with an example (thanks to Jason for some IRC 
> interaction):
> 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(; // 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.
> But I think any function that invokes an arbitrary other function in a 
> try has to fear that its finally might not run. There could be a hard 
> stop due to iloop prevention, or an uncatchable security fail-stop error.
> FWIW I'm cool on lambda and return to label atm.
> /be

More information about the es-discuss mailing list