`throw` as an expression?

2014-10-09 Thread Axel Rauschmayer
Use case: With promises, the expression body form of arrow functions is so convenient. Alas, `throw` being a statement, you can’t use it there. For example, the following code is not syntactically legal: ```js asyncFunc() .then(count = count = 0 ? count : throw new Error(...)) .then(...)

Re: `throw` as an expression?

2014-10-09 Thread Andrea Giammarchi
probably not exactly the fat arrow usage you were looking for ... but it makes it trivial to inline any sort of block ```js asyncFunc() .then(count = count = 0 ? count : ()={throw new Error(...)}()) .then(...) .catch(...); ``` Regards On Thu, Oct 9, 2014 at 1:23 PM, Axel Rauschmayer

Re: `throw` as an expression?

2014-10-09 Thread John Lenz
or a simple utility method On Thu, Oct 9, 2014 at 6:35 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: probably not exactly the fat arrow usage you were looking for ... but it makes it trivial to inline any sort of block ```js asyncFunc() .then(count = count = 0 ? count :

Re: `throw` as an expression?

2014-10-09 Thread Nathan Wall
On Thu, Oct 9, 2014 at 4:57 PM, John Lenz concavel...@gmail.com wrote: or a simple utility method Promise.reject could be used. ```js asyncFunc() .then(count = count = 0 ? count : Promise.reject(new Error(...))) .then(...) .catch(...) ``` Nathan

Re: `throw` as an expression?

2014-10-09 Thread Brendan Eich
John Lenz wrote: or a simple utility method Current keyword-anchored statement form does not require parens around expression to evaluate and throw. /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es

Re: `throw` as an expression?

2014-10-09 Thread Isiah Meadows
-discuss list es-discuss@mozilla.org Date: Thu, 9 Oct 2014 14:35:50 +0100 Subject: Re: `throw` as an expression? probably not exactly the fat arrow usage you were looking for ... but it makes it trivial to inline any sort of block ```js asyncFunc() .then(count = count = 0 ? count : ()={throw new

Re: `throw` as an expression?

2014-10-09 Thread John Lenz
parens around expression to evaluate and throw. /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss