On Mon, Dec 14, 2020 at 6:34 PM Larry Garfield <la...@garfieldtech.com> 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 > > -- > Larry Garfield > la...@garfieldtech.com > Just like Sara, I'm not strongly opposed to this, but I'm also not sure this is worthwhile. Writing "match (true) {" instead of "match {" is not particularly tedious when compared to the size of the remaining structure. Writing "match (true) {" has the advantage of being more explicit about what this actually does, namely a "true ===" comparison. If it is omitted, a reasonable person might think that match { preg_match(...) => ... } is going to do something sensible, like it would if placed inside an "if()". But it does not, as preg_match() returns 1, not true, and as such the match arm will never be taken. This is more obvious when the value that is being compared against is explicitly given. Of course, with "match {" being a dedicated syntax, we could make it a TypeError to use a non-bool match arm... Regards, Nikita