Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Rowan Tommins
On 12/04/2020 21:16, Ilija Tovilo wrote: Can match arms contain other flow control, such as "return" or "continue"? Yes and yes. They behave exactly the same as in the switch. This should definitely be described in the RFC. You didn't quote the second part of that question, which admittedly

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Ilija Tovilo
Hi Larry > That not only alleviates the need to support multi-line blocks, it keeps the > match statement itself clearer to understand at-a-glance, and encourages the > definition of named, testable, small blocks of code (ie, functions whether > anonymous or not), which is a net win on its own.

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Ilija Tovilo
Hi Rowan > Can match arms contain other flow control, such as "return" or "continue"? Yes and yes. They behave exactly the same as in the switch. This should definitely be described in the RFC. > Can I mix a bare value and a block as arms of the same match, or does the > whole construct need to

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Larry Garfield
On Sat, Apr 11, 2020, at 7:16 PM, Ilija Tovilo wrote: > Hi internals > > I'd like to announce the match expression RFC that replaces the switch > expression RFC I announced a few weeks ago. > New: https://wiki.php.net/rfc/match_expression > Old: https://wiki.php.net/rfc/switch_expression > > Due

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Mike Schinkel
I love everything about this, except for one deal killer. I love the use of =>. And I love the blocks. Plus I love that it can fully replace switch because of how using switch can easily allow an developer's oversight to introduce subtle bugs. The deal killer IMO is this: "match was added a

RE: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Iván Arias
>> Would be posible for blocks to require a return statement instead of raising >> an error? > >It would be possible for the blocks to return values (though not with >the return keyword). I've created a small prototype a few weeks ago: > >``` >$result = match ($x) { >0 => { >echo 'Foo'

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Rowan Tommins
On 12 April 2020 01:16:04 BST, Ilija Tovilo wrote: >Hi internals > >I'd like to announce the match expression RFC that replaces the switch >expression RFC I announced a few weeks ago. >New: https://wiki.php.net/rfc/match_expression >Old: https://wiki.php.net/rfc/switch_expression Hi Ilija, Thank

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Ilija Tovilo
Hi Iván > Would be posible for blocks to require a return statement instead of raising > an error? It would be possible for the blocks to return values (though not with the return keyword). I've created a small prototype a few weeks ago: ``` $result = match ($x) { 0 => { echo 'Foo';

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Iván Arias
> Hi internals > > I'd like to announce the match expression RFC that replaces the switch > expression RFC I announced a few weeks ago. > New: https://wiki.php.net/rfc/match_expression > Old: https://wiki.php.net/rfc/switch_expression > > Due to the feedback I decided to take the RFC in a slightly

Re: [PHP-DEV] [DISCUSSION] Match expression

2020-04-12 Thread Ilija Tovilo
Hi George I appreciate your feedback. > One small decision that I personally disagree with is the usage of `=>` > compared to using the colon as the switch statement does. I picked the `=>` symbol because IMO the extra spacing and wider symbol visually separates the two sides better. The differ