Re: [RFC][DISCUSSION] Match expression v2

From: Date: Mon, 22 Jun 2020 15:35:09 +0000
Subject: Re: [RFC][DISCUSSION] Match expression v2
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-110695@lists.php.net to get a copy of this message
Hi Ilija,Den 2020-06-18 kl. 22:51, skrev Ilija Tovilo:

Hi Björn
I'd like to announce the match expression v2 RFC: https://wiki.php.net/rfc/match_expression_v2
Well one could argue that when working with legacy code containing switch statements where one gradually migrates to match, it might be easier to have the same separator, i.e. ":".
I think that's somewhat of a moot point. The syntax of match is quite different (match instead of switch, no case, no break, colon instead of case, comma instead of semicolon, trailing semicolon). Just making one of those the same doesn't make a meaningful difference for ease of migration. Agree on that! One thing though. Is semicolon mandatory or is it optional
like in the first RFC? Feels a bit odd with a semicolon after a curly bracket.
Is the proposed => separator inspired by Rust or Scala? Checked what other languages used and for switch it's ":" of course. So one might argue that to align with match statements in other languages "=>" is a good choice, but OTOH if ones sees match as an enhanced switch, having ":" as a separator is another alternative.
Since nobody else asked for it, just for you I compiled a list of other languages :) https://gist.github.com/iluuu1994/11ac292cf7daca8162798d08db219cd5 The conclusion: Most languages also use some form of arrow. It makes sense to me to stay consistent with those languages. Ilija
I think this is a very good motivation on why select => as a symbol and I'm glad it's listed in the RFC. r//Björn

Thread (28 messages)

« previous php.internals (#110695) next »