super return

Andreas Rossberg rossberg at
Tue Aug 29 10:54:30 UTC 2017

On 28 August 2017 at 21:29, Sebastian Malton <sebastian at> 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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list