« Return to Thread: How would shallow generators compose with lambda?

Re: How would shallow generators compose with lambda?

by Mark S. Miller-2 :: Rate this Message:

Reply to Author | View in Thread

On Thu, May 14, 2009 at 1:22 PM, Brendan Eich <brendan@...> wrote:

> On May 14, 2009, at 12:24 PM, Jason Orendorff wrote:
>> 3. When a lambda yields, [...]
>> there may be other functions on the stack, in between. You can't
>> always statically tell which ones.  This means that generator
>> semantics affect the integrity of code that isn't in a generator.
>
> [...] this extends the finally integrity
> degradation outside of the lexical scope of the generator function. Good
> point.
>
>> [...] with generators+lambdas, almost any function call *anywhere* in the
>> program might never return or throw.  This weakens 'finally', at
>> least.
> [...]

> 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();


Thanks all, this has been very clarifying. You both have put your
finger on what was nagging at me and explained it clearly.

It seems that either lambda or generators by themselves may be ok, but
together they make a fatal combination. Whichever we might eventually
decide to add to Harmony, we probably forever preclude the other. I do
not yet have an opinion on which.

--

    Cheers,
    --MarkM
_______________________________________________
es-discuss mailing list
es-discuss@...
https://mail.mozilla.org/listinfo/es-discuss

 « Return to Thread: How would shallow generators compose with lambda?