On May 14, 2009, at 5:29 PM, David-Sarah Hopwood wrote:

Brendan Eich wrote:
On May 14, 2009, at 4:34 PM, David-Sarah Hopwood wrote:

This approach avoids any problems due to a generator being able
to interfere with the control flow of its callers.

A generator can't interfere with the control flow of its callers.

Can you give an example of what you meant by that?

I meant this:

Brendan Eich wrote:
Jason Orendorff wrote:
In ES5, when you call a function, you can expect it to return or throw
eventually.  (Unless you run out of memory, or time, and the whole
script gets terminated.) With shallow generators, this is still true. A 'yield' might never return control, but function calls are ok. But
with generators+lambdas, almost any function call *anywhere* in the
program might never return or throw.  This weakens 'finally', at
least.

To make this clear with an example (thanks to Jason for some IRC interaction):

function gen(arg) {
   foo((lambda (x) yield x), arg);

Yeah, you meant generators *plus* lambdas -- not just generators.

Leave out lambda and there's no effect on control flow in callers of the thing (generator function, not lambda) that yields.

/be

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to