On 29 August 2017 at 14:30, Sebastian Malton <sebast...@malton.name> wrote:

> If a function outlives its creation scope then this would do exactly what
> a normal return would do.
>

That makes no sense, because that's a completely different continuation,
usually expecting different, unrelated types of results. It needs to be an
error at least. (In a language with proper continuations the outer
continuation would be captured by the inner closure and invoking it later
would reestablish the execution context to return to. But TC39 always
agreed that we don't want full-blown continuations in JS.)


> *From:* rossb...@google.com
> *Sent:* August 29, 2017 6:55 AM
> *To:* sebast...@malton.name
> *Cc:* es-discuss@mozilla.org
> *Subject:* Re: super return
>
> On 28 August 2017 at 21:29, Sebastian Malton <sebast...@malton.name>
> wrote:
>
>> Thus I propose the new syntax `super return` and any other positive
>> number of supers. This syntax is currently not valid in any scenario and
>> with the current meaning of super seems, to me at least, relativity easy to
>> understand.
>>
>> The outcome of this basically means "return from current context up one
>> level and then return from there".
>>
>
> What if that context is no longer live? A function can outlive its
> creation scope. You could even try returning twice from the same function.
>
> Allowing returns from outer functions has been discussed extensively in
> the ES6 phase (e.g. under the term "blocks"), but has been decided against
> in favour of arrow functions. One problem is that it introduces quite
> complex dynamic behaviour in general (it's halfway to introducing delimited
> continuations), and many new ways to fail.
>
>
> A current method of doing this is by using try / catch but it is not
>> ideal. Using the above method I believe that it would be able to be better
>> optimized.
>>
>
> That's unlikely, since it is just as dynamic in the general case (and the
> less general cases can be optimised equally well for both).
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to