Hi Kevin,
On Tue 30 Apr 2013 11:05, Kevin Gadd <[email protected]> writes:
> I would definitely expect a given finally block to run if i use for-of
> or similar on the generator. This is the intent, I hope?
Certainly they run in this situation:
function *g1() { try { yield 1; } finally { qux(); } }
for (x of g1())
print (x)
Or in this one:
function *g2() { try { yield 1; return; } finally { qux(); } }
for (x of g2())
print (x)
But the question is what happens here:
function *g3() { try { yield 1; } finally { qux(); } }
for (x of g3())
break;
Or here:
function *g4() { try { yield 1; } finally { qux(); } }
for (x of g4())
throw "foo";
Or here:
function *g5() { try { yield 1; } finally { qux(); } }
for (x of g5())
call_function_that_throws_an_exception();
For me, it is acceptable in the last three cases to never invoke those
finally blocks. Otherwise, for-of would need to be implicitly
surrounded by a try/finally to manually "close" the generator. It
seems to me that it would have pretty negative perf implications; for
example Crankshaft doesn't currently run on functions with try/finally.
Regards,
Andy
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss