How would shallow generators compose with lambda?
Brendan Eich
brendan at mozilla.com
Thu May 14 13:49:28 PDT 2009
On May 14, 2009, at 1:47 PM, Waldemar Horwat wrote:
> 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.
Are you talking about generators, or lambdas?
Generators have no longjmps at all. The only issue here is due to the
lambda following Tennent's Correspondence Principle.
/be
>
>
> Waldemar
>
>
> 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(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.
>> 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