Den 2020-06-16 kl. 18:17, skrev Ilija Tovilo:
Hi Björn
I'd like to announce the match expression v2 RFC:
https://wiki.php.net/rfc/match_expression_v2
I do like this RFC and have one comment. Would it be suitable
to have : as a separator instead of =>?
`=>` is usually used in combination expressions (arrays, yield, arrow
functions). `:` is mostly used for switch cases and the alternative
control structure syntax [1]. `=>` also visually separates the
condition and expression better IMO. This has been suggested once
before but that's not enough for me to change it at this point.
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. ":".
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.
Anyway, I think it would be good if the RFC is updated with what other
languages uses, since that is a good motivation for why using "=>" as a
separator. What bothered me a little with that selection is the usage
of the "=>" symbol for other things in PHP. Hint, I was a fan of the
"==>" for arrow functions ;-)
r//Björn L
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php