> Le 4 févr. 2025 à 08:43, Dmitry Derepko <xepo...@gmail.com> a écrit : > > Hi, Larry! > >> On Feb 3, 2025, at 10:01 AM, Larry Garfield <la...@garfieldtech.com> wrote: >> >> On Sun, Feb 2, 2025, at 7:40 AM, Ilija Tovilo wrote: >>> Hi Dmitrii >>> >>> On Sun, Feb 2, 2025 at 1:05 PM Dmitry Derepko <xepo...@gmail.com> wrote: >>> >>> https://wiki.php.net/rfc/short-match >>> https://externals.io/message/112496 >> >> Hi, author of that RFC here. Although there seemed to be interest for it in >> the initial match() discussion, the stand-alone follow up was met with a >> giant "meh", which is why I didn't pursue it further. I would still be in >> favor of it, though, if it could get through internals. I'm happy to have >> someone pick it up and run with it, or collaborate on rebooting that RFC. >> (I'm pretty sure the patch for it actually worked, at least it did at the >> time.) >> >> --Larry Garfield > > > It looks funny that I’m following in your steps with the RFC’s didn’t go > through 😃 > > By the way, I’ve implemented empty match subject in a bit different way: > https://github.com/php/php-src/pull/17692 > > About the RFC. What’s the way to re-activate it? > Will you re-activate it? > Do I need to create a new one referencing to this one? > Can you share rights to edit the RFC and we can push it further together?
Hi, One issue to resolve is how to interpret: ```php $x = match { preg_match('/a/', 'a') => "will it be matched ..." , default => "... or not?" }; ``` knowing that preg_match(...) never returns `true`, but one of `0`, `1` or `false`. More generally, how to deal with truthy-but-not-true values. I see three options: (a) check for strict equality with `true` (i.e. make `match {}` equivalent to match(true) {}`). The `preg_match(...)` branch will never be taken; (b) check for truthy values. The `preg_match(...)` branch will be taken if the condition evaluates to 1; (c) mandate a boolean: The `preg_match(...)` branch will throw a runtime error if the condition evaluates to 0 or 1; Personnally, I am against option (a) as it is confusing and would be a source of bugs. —Claude