Super function

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Super function

Michael J. Ryan
What might be better is to extend break for named functions.

function someFn(arr) {
  return arr.map(e => {
    if(...) {
      break someFn return "...";
    }
    return e * 2;
  });
}

This way you know what you're breaking from.. super would imply one level deep.. break already has some similar constructs.  In this case it must be a named function or named variable assigned a function.  Not a reserved word (break while, break for, etc already works)


--
Michael J. Ryan - [hidden email] - http://tracker1.info

Please excuse grammar errors and typos, as this message was sent from my phone.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Super function

Sebastian Malton
This is actually exactly what I meant but it looks a lot better. It is also very clean

Sent: August 28, 2017 4:36 PM
Subject: Super function

What might be better is to extend break for named functions.

function someFn(arr) {
  return arr.map(e => {
    if(...) {
      break someFn return "...";
    }
    return e * 2;
  });
}

This way you know what you're breaking from.. super would imply one level deep.. break already has some similar constructs.  In this case it must be a named function or named variable assigned a function.  Not a reserved word (break while, break for, etc already works)


--
Michael J. Ryan - [hidden email] - http://tracker1.info

Please excuse grammar errors and typos, as this message was sent from my phone.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Super function

Isiah Meadows-2
Note: Kotlin has this [1], but it imposes numerous restrictions on its usage. There's no way you could accomplish this without either that, pseudo-exceptions, or both.


-----

Isiah Meadows
[hidden email]

Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com

On Mon, Aug 28, 2017 at 4:38 PM, Sebastian Malton <[hidden email]> wrote:
This is actually exactly what I meant but it looks a lot better. It is also very clean

Sent: August 28, 2017 4:36 PM
Subject: Super function

What might be better is to extend break for named functions.

function someFn(arr) {
  return arr.map(e => {
    if(...) {
      break someFn return "...";
    }
    return e * 2;
  });
}

This way you know what you're breaking from.. super would imply one level deep.. break already has some similar constructs.  In this case it must be a named function or named variable assigned a function.  Not a reserved word (break while, break for, etc already works)


--
Michael J. Ryan - [hidden email] - http://tracker1.info

Please excuse grammar errors and typos, as this message was sent from my phone.

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



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