OH JEEZ. Please ignore previous email. On Mon, Nov 17, 2014 at 12:00 PM, Jeremy Martin <jmar...@gmail.com> wrote:
> `validate: { ... }` > > Is that an ES7 feature? I don't recognize it from ES6, and can't seem to > find a relevant proposal with that syntax... > > On Mon, Nov 17, 2014 at 11:51 AM, Andreas Rossberg <rossb...@google.com> > wrote: > >> On 17 November 2014 17:29, Alex Kocharin <a...@kocharin.ru> wrote: >> > 17.11.2014, 03:07, “Biju” bijumaill...@gmail.com: >> >> I wish, I could write elegant two of the code pattern I use frequently. >> >> [...] >> >> Patten 2. >> >> I do like to code functions with early exit, like >> >> >> >> function someValidationProcess(){ >> >> >> >> doStuff(); >> >> if(condition_1()){ >> >> doCleanUp_1(); >> >> doCleanUp_2(); >> >> } >> >> >> >> doAnotherStuff(); >> >> if(condition_2()){ >> >> doCleanUp_1(); >> >> doCleanUp_2(); >> >> } >> >> >> >> doYetAnotherStuff(); >> >> if(condition_3()){ >> >> doCleanUp_1(); >> >> doCleanUp_2(); >> >> } >> >> >> >> doMoreStuff(); >> >> doCleanUp_1(); >> >> doCleanUp_2(); >> >> } >> >> Sounds like you would like to have monad comprehension syntax. :) >> >> > How about a loop? >> > >> > function someValidationProcess() { >> > do { >> > doStuff() >> > if (condition_1()) break >> > >> > doAnotherStuff() >> > if (condition_2()) break >> > >> > doYetAnotherStuff() >> > if (condition_3()) break >> > >> > doMoreStuff() >> > } while(0) >> > >> > doCleanUp_1() >> > doCleanUp_2() >> > } >> >> No need for a fake loop: >> >> function someValidationProcess() { >> validate: { >> doStuff() >> if (condition_1()) break validate >> doOtherStuff() >> if (condition_2()) break validate >> // etc. >> } >> doCleanUp_1() >> doCleanUp_2() >> } >> >> But I'd rather use a separate function for the clean-up. >> >> /Andreas >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > > > > -- > Jeremy Martin > 661.312.3853 > http://devsmash.com > @jmar777 > -- Jeremy Martin 661.312.3853 http://devsmash.com @jmar777
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss