Re: [RFC] Short-match

From: Date: Mon, 14 Dec 2020 22:55:14 +0000
Subject: Re: [RFC] Short-match
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-112506@lists.php.net to get a copy of this message
On 14.12.20 18:33, Larry Garfield wrote:
I present to Internals this tiny RFC to follow up on the match() expression RFC from earlier in the year. There was solidly positive support for this shortcut previously but it was removed for simplicity at the time, with the intent to bring it back later. It's now later. https://wiki.php.net/rfc/short-match
I think it is a good addition that will make code clearer. If the main counter-argument is that "if - elseif - else" does the same thing, comparing the syntax to that and showing some real-world examples might even convince some more people who think it is unnecessary, as the code mostly speaks for itself, but the example currently in the RFC might be a bit too simplistic to be convincing for the sceptics. It would also be interesting how much switch(true) is used in open source code currently, as it is the currently used "equivalent" to match(true) - I know it is in some parts of the Symfony code, probably because it is often easier to scan over when compared to huge if / elseif blocks. match(true) is clearly an improvement to switch(true), so while match has almost no use so far in PHP code, switch(true) definitely has.

Thread (29 messages)

« previous php.internals (#112506) next »