Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-26 Thread Ilija Tovilo
On 22.03.20, 18:17, "Dan Ackroyd" wrote: > $condition || throw new Exception('$condition must be truthy') > && $condition2 || throw new Exception('$condition2 must be truthy'); > > The "Deprecate left-associative ternary operator"* RFC made it so that > parentheses are required when ternary op

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-26 Thread Nikita Popov
On Sun, Mar 22, 2020 at 5:17 PM Ilija Tovilo wrote: > Hi everybody! I hope you’re doing well. > > > > Due to the modest feedback I’d like to move the throw expression RFC to > “under discussion”. > > https://wiki.php.net/rfc/throw_expression > > > > In short, the RFC proposes to convert the throw

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-25 Thread Ilija Tovilo
Hi Andrea > I would think we can just give `throw` an appropriate precedence so that > expressions like the above do what is desired The example are taken from the RFC online. The following expression is already possible: ```php throw $condition1 && $condition2 ? new Exception1() : new Excepti

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-25 Thread Andrea Faulds
Hi Dan, Dan Ackroyd wrote: Regarding the example: $condition || throw new Exception('$condition must be truthy') && $condition2 || throw new Exception('$condition2 must be truthy'); The "Deprecate left-associative ternary operator"* RFC made it so that parentheses are required when ternary

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-22 Thread Matthew Brown
I think this is great. It reminds me of a construct that Hack introduced called "as expressions": With throw expressions the Hack assignment, `$a = $b as string;` would be equivalent to the PHP assignment `$a = is_string($b) ? $b : throw new TypeError('$b must be a string');` If this passes,

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-22 Thread Mike Schinkel
> On Mar 22, 2020, at 2:39 PM, Ilija Tovilo wrote: > > Hi Mike > > Thanks for your feedback! > > Your solution works well and it's true that PHP would do just fine without > accepting this RFC. > However I do think this RFC makes sense for a few reasons: > > * I think that most people would e

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-22 Thread Ilija Tovilo
Hi Mike Thanks for your feedback! Your solution works well and it's true that PHP would do just fine without accepting this RFC. However I do think this RFC makes sense for a few reasons: * I think that most people would expect some of the examples (especially the arrow function) to be valid P

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-22 Thread Ilija Tovilo
Hi Dan Interesting suggestion. I'll have to think more about how many of these variations there are and if there's an easy way to recognize them. Ilija On 22.03.20, 18:16, "Dan Ackroyd" wrote: On Sun, 22 Mar 2020 at 16:17, Ilija Tovilo wrote: > > Due to the modest feedback I’d l

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-22 Thread Mike Schinkel
> On Mar 22, 2020, at 1:16 PM, Dan Ackroyd wrote: > > On Sun, 22 Mar 2020 at 16:17, Ilija Tovilo wrote: >> >> Due to the modest feedback I’d like to move the throw expression RFC to >> “under discussion”. >> >> https://wiki.php.net/rfc/throw_expression >> > > Regarding the example: > > $co

Re: [PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-22 Thread Dan Ackroyd
On Sun, 22 Mar 2020 at 16:17, Ilija Tovilo wrote: > > Due to the modest feedback I’d like to move the throw expression RFC to > “under discussion”. > > https://wiki.php.net/rfc/throw_expression > Regarding the example: $condition || throw new Exception('$condition must be truthy') && $conditi

[PHP-DEV] [RFC][DISCUSSION] throw expression

2020-03-22 Thread Ilija Tovilo
Hi everybody! I hope you’re doing well. Due to the modest feedback I’d like to move the throw expression RFC to “under discussion”. https://wiki.php.net/rfc/throw_expression In short, the RFC proposes to convert the throw statement into an expression to make it usable in arrow functions,