I don't understand what's the advantage of the short match? Why would I ever want to use it? If I ever saw this kind of code in my codebase then I would immediately refactor it to use if statements. That is just abuse of match statement in my opinion. If someone wants to abuse match syntax like this then I think they should put (true) after it to make it clear what they are doing. Allowing match without the match subject will be lead to confusing problems for a lot of beginners who will forget the match subject or mis-copy it and then wonder why their application does not behave as it should. IMHO I see no benefit of adding this feature to PHP, and I actually see disadvantages.
On Mon, 14 Dec 2020 at 21:23, Sara Golemon <poll...@php.net> wrote: > > On Mon, Dec 14, 2020 at 2:24 PM Doug Nelson <dougnel...@silktide.com> wrote: > > > Both you and Sara at different points have talked about thinking was bad > > practice, but I've not read anything compelling about why it should be > > considered as such. > > > > > I'm not a full -1 on the concept (especially as match(true) has the > convenience of returning a value), but it's very square peg in a round hole > to me. > > At the end of the day though, that's a style choice and not one I have any > business imposing on anyone, and certainly within the context of this diff, > the actual change is trivial. It's sugar for match(true) that looks like > match. /shrug > > I might suggest broadening the scope to include `switch` as well though. > If we're going to codify match(true) as a pattern, we should at least be > consistent about it. > > -Sara -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php